Wiping a Drive on Linux

Wiping a Drive on Linux
Photo by Clay Banks / Unsplash

This may be the shortest post I ever make.

Sometimes a disk fights with you, and all you want to do is quickly obliterate the entire partition table & every partition on it. The command I have found to work the vast majority of the time, even when dealing with stubborn MDADM & ZFS data, is this:

wipefs -a -f /dev/SD?

Replace /dev/SD? with the location of the device. Remember, you can find that with the lsblk & blkid commands.

If you want to completely overwrite all of the data on a drive with random nonsense, and you don't mind waiting a proportional amount of time based on the speed and size of the drive, this command ought to do you:

dd if=/dev/urandom of=/dev/SD? status=progress

Again, replace /dev/SD? with the location of your device. This is a great option if you plan to donate or sell a drive. The status=progress option may not work on all systems. If it doesn't, this will sit at a blank screen with no indication of what is happening until it is done. In *nix, no news is good news.

That's it. Good luck.