This answer is appended as a solution for all those older Apple Mac versions, such as Snow Leopard 10.6.8, where "FAT32" as the filesystem type does NOT work as per the example below:
$diskutil eraseDisk fat32 mydiskname MBRFormat /dev/disk1
fat32 does not appear to be a valid file system format
Use diskutil listFilesystems to view a list of supported file systems
The internal command is:
diskutil eraseDisk filesystem disklabel MBRFormat device
where device is determined to be your SD Card using the command diskutil list
.
Find the correct filesystem alias by typing this in Terminal:
$diskutil listFilesystems
Formattable filesystems
These file system personalities can be used for erasing and partitioning.
When specifying one as a parameter to a verb, case is not considered;
also, diskutil allows certain aliases which are themselves case-insensitive.
-------------------------------------------------------------------------------
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)
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+
In the output above you will see that there are aliases defined by "(or) something" but there is no alias for the FAT32 filesystem. You must specify the full name "ms-dos fat32" regardless of case.
Therefore, for an SD card connected as /dev/disk1, the correct procedure is:
- Close any applications and
exit
any terminal prompt accessing the disk.
- If you want to do everything manually then unmount the disk using:
$diskutil unmountDisk /dev/disk1
However, diskutil automatically attempts to unmount it.
- Enter the following command, specifying your disk label and device appropriately:
$diskutil eraseDisk "ms-dos fat32" mydiskname MBRFormat /dev/disk1
Output is:
Started erase on disk1
Unmounting disk
Creating partition map
Waiting for disks to reappear
Formatting disk1s1 as MS-DOS (FAT32) with name mydiskname
Finished erase on disk1
Finally, check the result using diskutil list
:
$diskutil list /dev/disk1
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *1.0 GB disk1
1: DOS_FAT_32 MYDISKNAME 1.0 GB disk1s1
Seems like disk numbers greater than 1 should be used in all answers to this lest users erase their main drive. I know most main drives are disk0s but still, let's add a margin of safety – JohnAllen – 2016-02-29T17:08:15.490