Info
Content

How to wipe a hard drive in Linux


How to wipe a hard drive clean in Linux

You may need to wipe you hard drive to clean up partition errors, bad installations, or for privacy. This will show you how to do this.

These methods use a command called 'dd'

Wiping the entire disk:
dd if=/dev/zero of=/dev/sdX bs=1M *replace X with the target drive letter.

If you are wiping your hard drive for security, you should populate it with random data rather than zeros (This is going to take even longer than the first example.) :
dd if=/dev/urandom of=/dev/sdX bs=1M *replace X with the target drive letter.

Wiping the Master Boot Record (MBR):
dd if=/dev/zero of=/dev/hdX bs=446 count=1 *replace X with the target drive letter.

Wiping the last sectors of a disk can be done with the following command:
dd bs=512 if=/dev/zero of=/dev/sdx count=2048 seek=$((`blockdev --getsz /dev/sdx` - 2048))

No Comments
Back to top