Mike's PBX Cookbook

Formating FAT32

A drive, which refused to format correctly under Windows (reporting incorrect size), was quickly revived with MacOS's diskutil command in Terminal. Attach the drive via an IDE or SATA to USB adapter, and open the Terminal program. Then...

1 Find the disk device identifier: diskutil list

$ diskutil list
/dev/disk3 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *8.4 GB     disk3   ← this one!
   1:                 DOS_FAT_32 U                       8.4 GB     disk3s1

Note, disk3 refers to the entire disk, whereas disk3s1 refers to partition 1 on disk 3. The letter 's' means 'slice' (partition).

2 Now erase and partition it: sudo diskutil eraseDisk FAT32 UNTITLED MBR /dev/diskX

$ sudo diskutil eraseDisk FAT32 UNTITLED MBR /dev/disk3
Password: ******                                              ← enter your password
Started erase on disk3
Unmounting disk
Creating the partition map
Waiting for partitions to activate
Formatting disk3s1 as MS-DOS (FAT32) with name UNTITLED
512 bytes per physical sector
/dev/rdisk3s1: 16352024 sectors in 2044003 FAT32 clusters (4096 bytes/cluster)
bps=512 spc=8 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=2 drv=0x80 bsec=16383998 bspf=15969 rdcl=2 infs=1 bkbs=6
Mounting disk
Finished erase on disk3

From the diskutil man page:

eraseDisk format name [APM | MBR | GPT] device
Erase an existing disk, removing all volumes and writing out a
new partitioning scheme containing one new empty file system volume.

Above, we specify 'FAT32', and 'Master Boot Record' for DOS/Windows compatibility. See the man page for more details.
If you want to create multiple partitions, and/or specify partition size, use partitionDisk instead.

CAUTION! This procedure refers to disk3, but your device identifier can be different. Check it first!