Removing All Partitions in Mac OS X

When setting up a new TrueCrypt device under Mac OS X, you may receive this message if you try to encrypt a whole disk rather than a partition:

device-contains-partitions

I could not find a way to remove the partition via the Mac OS X Disk Utility, so I resorted to some terminal work. By clobbering the first few bytes of the disk’s partition map, I essentially made the whole disk look like random garbage, and TrueCrypt no longer presented a warning. This will cause data loss, so be careful.

First, find the drive’s device number using Disk Utility. Right click on the drive (not one of the partitions) and select “Information.”

right-click-info

Look for “Disk Identifier” in the property list. In this case, my drive is called disk3, which corresponds to /dev/disk3 on the filesystem. Tomorrow it might be disk4 or disk6, so don’t make any assumptions here. Failure to find the correct drive number in this step will cause you to erase the wrong drive in a future step.

device-information

Open up your terminal and umount this disk’s volumes. Note the asterisk, which should be included in your command.

  • sudo umount -f /dev/disk3*

Unmounting drives in the Finder will make the disk unavailable in /dev, and we need this block device if we’re going to clobber the filesystem.

Once the partitions are unmounted, we can write junk to the partition table and essentially unformat the drive. This is the dangerous part, so don’t screw it up or you will destroy the wrong drive, lose all your data, and seriously hate life. Replace disk3 with your drive identifier!

  • sudo dd if=/dev/zero of=/dev/disk3 bs=1 count=1024

After writing zeroes to the front of the drive, TrueCrypt happily made an encrypted volume on the disk.

3 Comments

  1. Surge says:

    Awesome man, thank you SO much.
    I really friggen hate OS X’s disk utility — even if you format a disk as “Free Space” it STILL leaves a partition table on it.
    I don’t use truecrypt but I do benchmarks on OS X all the time (With IOMeter \Dynamo) — in order for Dynamo to report a disk as “raw” to Iometer, the disk must have NO partitions on it…my old solution was to keep a Windows partition on the Mac Pro and boot to that, wipe the drives with diskpart, and then boot back into OS X…no longer thanks to this.  Bookmarked and Kudos :)

  2. Jon says:

    You, sir, are my hero.

  3. Shawn says:

    sudo diskutil zeroDisk /dev/disk should work as well through the terminal. Just plug the disk in and do a diskutil list find your physical device address and voila.

Leave a Comment

HTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>