Sunday, October 11, 2015

USB Formatting to Support Windows using Mac Command Line Tool

Abstract

It's an annoying problem that Windows isn't support much filesystem formats; thus, usually we meet problems when we plug our USB flash disk, which was formatted by Mac, into Windows machines. Although it seems that this can be solved easily by formatting the disk again to FAT or exFAT, still different problems will exist, such as different version of Windows supporting different types of filesystem, etc.

Anyway, I am writing this post to record how I solved this problem efficiently, so it may help someone or myself in the future.

Steps

A. Locate disk identifier

> diskutil list
...
/dev/disk4 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *8.0 GB     disk4
   1:                 DOS_FAT_32 HERON                   8.0 GB     disk4s1

B. Check Status

If you want to read the information about the disk:
> diskutil info disk4
   Device Identifier:        disk4
   Device Node:              /dev/disk4
   Whole:                    Yes
   Part of Whole:            disk4
   Device / Media Name:      SanDisk Cruzer Fit Media
   Volume Name:              Not applicable (no file system)
   Mounted:                  Not applicable (no file system)
   File System:              None
   Content (IOContent):      FDisk_partition_scheme
   OS Can Be Installed:      No
   Media Type:               Generic
   Protocol:                 USB
   SMART Status:             Not Supported
   Total Size:               8.0 GB (8004304896 Bytes) (exactly 15633408 512-Byte-Units)
   Volume Free Space:        Not applicable (no file system)
   Device Block Size:        512 Bytes
   Read-Only Media:          No
   Read-Only Volume:         Not applicable (no file system)
   Device Location:          External
   Removable Media:          Yes
   Media Removal:            Software-Activated
   Virtual:                  No
   OS 9 Drivers:             No
   Low Level Format:         Not supported

C. Verify Volumes

If you want to verify if there's any issue of the current disk:
> diskutil verifyVolume /Volumes/HERON
Started file system verification on disk4s1 HERON
Verifying file system
** /dev/rdisk4s1
** Phase 1 - Preparing FAT
** Phase 2 - Checking Directories
** Phase 3 - Checking for Orphan Clusters
79 files, 7800596 KiB free (1950149 clusters)
File system check exit code is 0
Finished file system verification on disk4s1 HERON

D. Repairing Volumes

If you found any problem and want to repair the disk:
> diskutil repairVolume /Volumes/HERON
Started file system repair on disk4s1 HERON
Repairing file system
** /dev/rdisk4s1
** Phase 1 - Preparing FAT
** Phase 2 - Checking Directories
** Phase 3 - Checking for Orphan Clusters
77 files, 7800608 KiB free (1950152 clusters)
File system check exit code is 0
Updating boot support partitions for the volume as required
Finished file system repair on disk4s1 HERON

E. Format

To format the disk in order to support Windows' FAT:
> diskutil eraseDisk MS-DOS HERON_2 /dev/disk4
Started erase on disk4
Unmounting disk
Creating the partition map
Waiting for the disks to reappear
Formatting disk4s2 as MS-DOS (FAT) with name HERON_2
512 bytes per physical sector
/dev/rdisk4s2: 15191032 sectors in 1898879 FAT32 clusters (4096 bytes/cluster)
bps=512 spc=8 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=411648 drv=0x80 bsec=15220736 bspf=14836 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished erase on disk4
To learn filesystems that supported by diskutil:
> diskutil listFilesystems
Formattable file systems
These file system personalities can be used for erasing and partitioning.
When specifying a personality as a parameter to a verb, case is not considered.
Certain common aliases (also case-insensitive) are listed below as well.
-------------------------------------------------------------------------------
PERSONALITY                     USER VISIBLE NAME
-------------------------------------------------------------------------------
ExFAT                           ExFAT
Free Space                      Free Space
  (or) free
MS-DOS                          MS-DOS (FAT)
MS-DOS FAT12                    MS-DOS (FAT12)
MS-DOS FAT16                    MS-DOS (FAT16)
MS-DOS FAT32                    MS-DOS (FAT32)
  (or) fat32
HFS+                            Mac OS Extended
Case-sensitive HFS+             Mac OS Extended (Case-sensitive)
  (or) hfsx
Case-sensitive Journaled HFS+   Mac OS Extended (Case-sensitive, Journaled)
  (or) jhfsx
Journaled HFS+                  Mac OS Extended (Journaled)
  (or) jhfs+
If you are using GUI disk utility, make sure you picked "Master Boot Record":


Just in case that you found unable to unmount volume error, make sure you're not in volume folder when diskutil is trying to umount:

/Volumes/HERON_2
> diskutil verifyVolume /Volumes/HERON
Unable to find disk for /Volumes/HERON
/Volumes/HERON_2
> diskutil verifyVolume /Volumes/HERON_2
Started file system verification on disk4s2 HERON_2
Error: -69673: Unable to unmount volume for repair
/Volumes/HERON_2
> diskutil verifyVolume /Volumes/HERON_2
/Volumes/HERON_2
> cd ..
/Volumes
> diskutil verifyVolume /Volumes/HERON_2
Started file system verification on disk4s2 HERON_2
Verifying file system
** /dev/rdisk4s2
** Phase 1 - Preparing FAT
** Phase 2 - Checking Directories
** Phase 3 - Checking for Orphan Clusters
83 files, 7594648 KiB free (1898662 clusters)
File system check exit code is 0
Finished file system verification on disk4s2 HERON_2

Reference

3 comments:

  1. Harrah's Casino | CommunityKhabar
    Harrah's Las 더킹카지노 Vegas Hotel & Casino is a Wedding Venue 메리트카지노 in Las Vegas, NV. It has 2,700 rooms in five towers, 바카라 a full-service spa, and a full-service

    ReplyDelete
  2. Thank You and that i have a swell give: Who Does House Renovation victorian home renovation

    ReplyDelete