How to securely Wipe a Hard Drive – Step by Step

To securely wipe a hard drive, boot a USB stick with ShredOS (nwipe), select the drive and run a full overwrite. That suits spinning hard disks. For SSDs and NVMe drives, use the drive’s own secure erase instead. DBAN is outdated and cannot erase SSDs.
Short version
# Spinning hard disk: write ShredOS to a USB stick (Linux example), boot it, select the drive, press S
sudo dd if=shredos.img of=/dev/sdX bs=4M status=progress conv=fsync
# SATA SSD: ATA Secure Erase (drive must not be frozen, connect it directly, not via USB)
sudo hdparm --user-master u --security-set-pass Eins /dev/sdX
sudo hdparm --user-master u --security-erase Eins /dev/sdX
# NVMe SSD: user data erase (check the device name first)
sudo nvme format /dev/nvme0n1 --ses=1Replace /dev/sdX with the right device. These commands destroy data without asking twice.
There are endless reasons on why you would want to securely wipe a Hard Drive. Some of them might be, you want to sell your old computer and don’t want your data to be recoverable, or you work for a company that requires certain standards before handing out a new device to a new employee, over of course, you don’t want your favorite Britney Spears songs being discovered by a third party.
Gladly, it is very straight-forward and easy to Securely Wipe a Hard Drive. I’ll show you through the process, step by step.
Pick the right method for your drive
- Spinning hard disk (HDD): overwrite it with ShredOS (nwipe) or DBAN. Both are covered below.
- SATA or NVMe SSD: use the drive’s built-in erase. Overwriting is often not enough for flash storage, see the SSD section below.
- Old BIOS-only machine: DBAN still boots there, but ShredOS supports both BIOS and UEFI, so I recommend ShredOS.
What you need
- A USB drive with at least 4GB of space
- Rufus (or Etcher, or
ddon Linux) - The ShredOS image, a small bootable system that runs nwipe. Use the
.imgfile for a USB stick. - Optional: DBAN (Darik’s boot and nuke), the older tool this post originally used
Downloading Rufus and creating a bootable USB drive
To be able to run the wiping tool, we need to create a bootable USB drive. That is very easy. First, download the ShredOS .img file (or the DBAN.iso file if you go the DBAN route). After that, go ahead and download and start Rufus.
Once you have Rufus started, make sure to select the correct USB drive. Be aware that ALL DATA on the USB drive will be deleted!
Next, click on SELECT and choose the image file from your downloads folder. Click START once you have all set up. The screenshot below shows an older Rufus version and the DBAN image, the current Rufus window looks different but works the same way.

The process should be done rather quickly. Once you are done with this, remove the USB drive from your PC and plug it in the laptop/computer where you want the hard drive to be wiped.
Booting from a USB drive
ShredOS boots in both BIOS and UEFI mode, so you can usually leave your firmware settings alone. DBAN only boots in Legacy Boot Mode (or Legacy and UEFI with Legacy first), so switch the setting if you use it. You need to enter your computer’s BIOS setup for this. This process will be slightly different on each manufacturer, I, for example, use a Thinkpad for this demonstration. I need to press the Enter button right after switching the computer on.
The best way to find out how you can access your model’s bios is by simply googling: “MyComputerModel enter BIOS”.
For DBAN, navigate to Startup and either select only Legacy or Legacy & UEFI like in the screenshot below.

Next, navigate to Restart and select Save Changes and Exit or something along those lines. When the computer restarts, smash that like button (Damn you, Peter McKinnon!), I mean, smash that boot Menu button. You can find out which button it is, again, by googling: “MyComputerModel enter boot menu”.
Once you are in the boot menu, select your USB flash drive to boot from it.

Securely Wipe a Hard Drive with ShredOS (nwipe)
ShredOS starts the nwipe interface automatically after booting. Select the drive you want to wipe, choose a method (the defaults are fine for most people), and press S to start. Check the drive selection twice before you do.
You can also add --autonuke to the kernel command line via nwipe_options in grub.cfg to wipe without any confirmation prompt. Only do that if you are sure which drives are attached.
Press ALT-F2 for a shell or ALT-F3 for the console log if you want to see what is going on.
How to Securely Wipe a Hard Drive with DBAN
DBAN is the tool I used when I first wrote this post. Its own site says it cannot detect or erase SSDs and gets no software updates, so only use it on an old spinning disk. nwipe, the tool inside ShredOS, is a fork of DBAN’s wipe program.
If you followed each step correctly, you should now see Darik’s Boot and Nuke main menu.

From here, you have a couple of options. For one, you could just type autonuke and hit enter, this will use an automatic algorithm to wipe your hard drive. Be careful tho, I highly discourage you from doing this if you have multiple hard drives in your computer next to the one you want to wipe.
The safer method is just hitting enter to get into the interactive mode.
Once you are there, you have to select the hard drive you want to wipe. Make sure to choose the correct one and hit the space button.

You could just hit F10 to start the process now, leaving everything as default and you are fine. The default options are great for everyone. However, if you want more control over which algorithm is being used for the deletion, you can adjust that by pressing the M key.

You have to google your way through each algorithm if you want to understand what they do. Leaving it on default, as mentioned, is perfectly fine for most users. In the main menu, you are also able to choose different values for verification, how many rounds the algorithm will go, etc. Those are all advanced options that need further reading. I will only cover the basic functionality here.
Once you have everything set up, hit F10 to start with wiping your hard drive. Take note, this can take a very long time depending on the hard drive size.
It can take several hours.

Securely Wipe an SSD or NVMe Drive
Overwrite tools write to every block the operating system can see. SSDs also have wear levelling, overprovisioned space and remapped blocks the system cannot address, so a plain overwrite is often not enough. The nwipe project recommends a hardware secure erase first, then at least one full overwrite pass on top.
Run these from a Linux live system and connect the drive directly to the motherboard. USB adapters and RAID controllers can make the commands fail or reset the drive.
SATA SSD (ATA Secure Erase):
sudo hdparm -I /dev/sdX
sudo hdparm --user-master u --security-set-pass Eins /dev/sdX
sudo hdparm --user-master u --security-erase Eins /dev/sdXThe first command must show the drive as “not frozen”. Use hdparm 9.31 or newer, older versions have a fixed two hour timeout. The ShredOS documentation says SANITIZE is preferred over SECURITY ERASE UNIT where the drive supports it, so check man hdparm for the sanitize options.
NVMe SSD:
sudo nvme list
sudo nvme format /dev/nvme0n1 --ses=1--ses=1 is a user data erase and --ses=2 is a cryptographic erase, if the drive supports it. The number in a device name does not tell you which controller owns it, so verify the target before you run it.
blkdiscard: sudo blkdiscard -s /dev/sdX requests a secure discard, but only works if the device supports it. A plain discard is not documented as a guarantee that the data is gone.
FAQ
Does DBAN work on SSDs?
No. DBAN’s own site says it cannot detect or erase SSDs, and it was built for BIOS machines. Use ShredOS for hard disks and the drive’s secure erase for SSDs.
Is deleting files or formatting enough before I sell my computer?
No. Deleting files and quick formatting mostly remove the pointers to the data, so recovery tools can often bring it back. Wipe the whole drive with an overwrite tool or the drive’s secure erase.
How long does wiping a drive take?
It depends on the drive size and speed. A full overwrite of a large hard disk takes hours. An ATA Secure Erase on a small SSD can finish in under a minute, while a 1TB hard disk can take three hours or more.
How do I securely erase an SSD or NVMe drive?
Use the drive’s own erase command: hdparm --security-erase for SATA SSDs or nvme format --ses=1 for NVMe. Overwriting alone often misses blocks on flash storage, see the SSD section above.
Why does hdparm say my drive is frozen?
The firmware locks the security features at boot, so Secure Erase cannot run. A common fix is to suspend and wake the machine, for example with rtcwake -m mem -s 5, then check hdparm -I again.
Conclusion
The process of securely wiping your hard drive takes a bit of effort but is definitely worth the hassle. You don’t want somebody to be able to recover your personal data when you are selling your old device.
One thought on “How to securely Wipe a Hard Drive – Step by Step”
Comments are closed. I keep the discussion here because the answers still help.
More posts
All SysAdmin


HI,
Is it usefull to do this on a SSD drive like you do ?
I heard that, the SSD drive don't keep data like the HARDDRIVE does, so it looks like useless , on a SSD drive however, and it is dangerous for it .
Thanks for your answer.