Securely erase hard drive on Ubuntu (unrecoverable shred command)
Did you ever want to securely erase a hard disk on your server so the data is unrecoverable? Maybe you are selling the drive or the computer and want to be sure that no sensitive data can be recovered by a future owner. Ubuntu has a command line tool for just that purpose. If you want to completely erase the drive your system is on, first boot your computer using a Ubuntu LiveCD or the server install disk. Then, from the terminal (located in Applications->Accessories->Terminal if you use the Desktop LiveCD) enter the shred:
sudo shred -vfz -n [times] [your hard drive]
For example, you could type
sudo shred -vfz -n 5 /dev/sda
This would overwrite the data on the drive in /dev/sda with random data in 5 passes – the default is 3. Then it would overwrite the drive one more time with just zeros in a sixth pass. The parameters mean the following (see man shred for more):
- v
- Verbose output (see everything on screen)
- f
- Force permission changes (so you can overwrite everything
- z
- Overwrite with zeros (so it’s extra unrecoverable) in one more pass at the end
Overwriting your data with zeros through shred adds extra security, as does repeating the process a few times. 5 times may be a bit overkill though. Even overwriting it with random data once should be secure enough for most purposes. If you are paranoid about security or have truly sensitive data, you may try a higher number. Keep in mind that this increases the time required dramatically! Even on just a 500 GB hard drive (5400 rpm), a single pass with a final overwrite with zeros can take more a day.
Note: shred can also be used to overwrite individual files. However, this does not work well on modern operating systems for the reasons outlined in man shred.
June 2nd, 2010 at 3:25 pm
[...] sudo shred -vfz -n [times] [your hard drive] — For more information on shred [...]
August 11th, 2010 at 11:01 pm
awesome only if we could do 35 pass in a matter of minutes lol.