How to wipe a disk in Linux

Imagine, you have a hard disk drive and want to give it away, sell it or return it to vendor. But you have some sensitive data on it, so you better clean the disk up before doing so, so that nobody ever can recover any data from the disk.

It is very easy to do this in Linux. You even do not need any special tools for that. Just use the standard dd utility to fill the disk up with either random data or zeroes.

Below is an example of wiping whole of an external USB disk, destroying MBR, FAT etc.

Option 1: Use random data to overwrite all of the disk contents.

dd if=/dev/urandom of=/dev/sdb bs=1M

Option 2: Use zeroes to overwrite all of the disk contents.

dd if=/dev/zero of=/dev/sdb bs=1M

Note 1: If you would like to wipe only a partition instead of the whole disk, you would say, for example, /dev/sdb1 instead of the /dev/sdb.

Note 2: Using random data theoretically gives you better degree of protection than using zeroes, though some argue that in real life it is irrelevant and for practical purposes both methods are equally good. Please note, that using random data is considerably slower than using zeroes. It took me a bit more than 2 days to wipe 1 TB USB disk using random numbers, and a bit less than 1 day to do the same with zeroes.

Advertisements

5 Comments on “How to wipe a disk in Linux”

  1. element90 says:

    Or option 3 use shred which can be used to shred partitions or whole discs as well as individual files.

    e.g:

    shred -v /dev/sda

    -v switches on verbose mode so that you can see hoe it is getting on.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s