2

The command 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.

4

Enter 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 ....


The 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.

| improve this answer | |
3

The command is newfs_msdos.

Also for HFS+, the command is newfs_hfs.

Use 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.

Finally, use diskutil mount identifier.

For example.

diskutil list
diskutil unmount /dev/disk0s4
newfs_msdos -F 32 -v BOOTCAMP /dev/disk0s4
diskutil mount /dev/disk0s4

Note: Using 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.

| improve this answer | |
  • I will include your eraseVolume addendum in my answer, so it will not mess your answer :-)! – klanomath Oct 24 '16 at 16:17

Not the answer you're looking for? Browse other questions tagged .