diskutil eraseDisk is not what I want because that wipes the entire disk. I have a partition already allocated and it is blank. All I need to do is format it with VFAT/FAT32. How can this be done from Terminal? It must the same effect as using
mkfs.vfat on Linux.
diskutil list to get the disk identifier/partition. Then enter:
diskutil eraseVolume FAT32 DATA diskXsY #replace diskXsY by the proper disk identifier
DATA will be the name of the volume. The name has to be capitalized using
diskutil eraseVolume ... command will change the pMBR of the GUID partition table to a hybrid MBR and probably renders an existing OS X system volume on the same drive unbootable.
The command is
Also for HFS+, the command is
man newfs_msdos or
man newfs_hfs for more information.
Generally, you would use
diskutil list to get the slice (identifier).
Next you use
diskutil unmount identifier, followed by the format command.
diskutil mount identifier.
diskutil list diskutil unmount /dev/disk0s4 newfs_msdos -F 32 -v BOOTCAMP /dev/disk0s4 diskutil mount /dev/disk0s4
diskutil to format a partition (slice) can have the side effect of altering the type of partitioning a drive is using.
For example, the command
diskutil eraseVolume fat32 BOOTCAMP /dev/disk0s4
can result in changing a GPT partitioned disk into a hybrid GPT/MBR partitioned disk.