OS X – Formatting SD Card from Terminal

I’ve got a MacBook Pro 17″, this is a 2011 model but it’s my work horse. These systems had a little slot where you can plug in an ExpressCard/34 size device. The OCD in me want to put something in there so I bought for like $5 a SanDisk SD Adapter. So now I can put SD cards directly into this system.

I can see the SD cards when I insert them but it kept failing when I tried to erase them with the Disk Utility tool. So off to the command line I went. First off, you gotta find which device is the SD card. So you will do a:

diskutil list

I got the following output and I can see that the 8GB device at /dev/disk2 is my SD card.

Now you need to issue the command to erase and format the SD card. Here is the command and I’ll explain the options:

diskutil eraseDisk FAT32 SDCARD MBRFormat /dev/disk2

“diskutil” is the utility program. “eraseDisk” is the command/action you are telling it to perform. “FAT32” is telling it to format the SD card with Fat32. “SDCARD” is just what to name the SD once formatted. “MBRFormat” is to set it up with a Master Boot Record. “/dev/disk2” is the device we are targeting. If all goes well, you should see something like:

That’s it. Two commands and you are off to the races!!