How to erase or wipe a hard drive and MBR using linux
Sometimes you may need to wipe your hard drive for either security reasons or just to have a clean hard drive. Here are a few commands you can use under linux to wipe either the entire hard drive or just the MBR. You can do this with all 0’s or random data for security.
These instructions are assuming you’re wiping /dev/sda, replace this with your correct drive. If you want to wipe just partitions you can use /dev/sda1, or /dev/sda2, etc.
This will wipe the drive, including all partitions, and the MBR changing every bit of data to a 0
1 |
dd if=/dev/zero of=/dev/sda bs=1M |
Wipe just the MBR
1 |
dd if=/dev/zero of=/dev/hda bs=446 count=1 |
If you’re wiping the drive for security reasons you should use random data instead
1 |
dd if=/dev/urandom of=/dev/sda bs=1M |