Wednesday, August 26, 2015

Securely Erasing Free Space in Mac OS X

There are two ways to erase free space in Mac OS X, one is using the GUI application Disk Utility, the other is using Terminal.

The one-line Terminal command to scrub free space of existing data is

diskutil secureErase freespace 3 /Volumes/"drive"

You can get the name of your drive by using the following two basic commands to look up the available system drives:

cd /Volumes/

ls


This will list the available drives, which you can copy and paste into the above command for the "drive" path. The command will write to each drive sector 35 times. Thirty-five passes is well above the U.S. Department of Defense’s own standard 7 pass standard for erasing data. Note that with large capacity drives, this process may take a very long time (perhaps hours or days) to complete due to the capacity and work that needs to take place to do a 35-pass wipe of the data. Though I used Yosemite 10.10 this should work no problem in Snow Leopard 10.6, Lion 10.7, Mountain Lion 10.8, Mavericks 10.9, or El Capitan 10.11