Overwrite Hard Drive with Zeros on Linux: Fast & Easy!

To overwrite a hard drive with zeros on Linux, find the device with lsblk, then run sudo dd if=/dev/zero of=/dev/sdX bs=1M status=progress conv=fsync. For one random pass plus a final zero pass, use shred -v -n1 -z instead. Both suit hard disks, not SSDs.

Short version

Terminalbash
# 1. Find the right device (check the size and model!)
lsblk

# 2a. Zeros only
sudo dd if=/dev/zero of=/dev/sdX bs=1M status=progress conv=fsync

# 2b. Or: one random pass, then a final pass of zeros
sudo shred -v -n1 -z /dev/sdX

Replace /dev/sdX with your drive. Both commands destroy all data on it without asking again. For SSDs and NVMe drives, use the drive’s own secure erase instead. I cover that in How to securely Wipe a Hard Drive.

Did you buy a used Hard Drive and are now uncomfortable using it as it is? Well, there is a safe way to make sure you completely wipe that Drive. We achieve this by Overwriting the Hard Drive with Zeros. We are going to use Linux to do this. Linux comes pre-equipped for that task with tools called dd and Shred.

Step 1 - Selecting the correct Hard Drive

We first need to find out which Drive Letter our Hard Drive has so we are not accidentally erasing the wrong Hard Drive.

Terminalbash
sudo fdisk -l

Now find your Hard Drive by using its Size as an Indicator. My external Drive is 3TB, so it’s pretty easy to distinguish from my other Drives.

Overwrite Hard Drive with Zeros
Overwrite Hard Drives with Zeros: Finding the correct Hard Drive

My Drive has the Drive Letters sde.

Step 2 - Overwrite the Hard Drive with Zeros using Shred

Now we are going to Overwrite our Hard Drive with Zeros. Double and triple-check if you really have the correct drive selected. That thing will get wiped clean after running the next command.

Snippettext
sudo shred -v -n1 -z /dev/sdX

The -v Tag stands for Verbose, the -n1 Tag stands for “One Time” and the -z Tag stands for Zeros. So Shred will run one random pass verbosely and then add a final pass of zeros. The -z option adds a pass on top of the random ones, it does not replace them.

If you want zeros only, use dd instead:

Terminalbash
sudo dd if=/dev/zero of=/dev/sdX bs=1M status=progress conv=fsync

I don’t recommend shred -n0 -z for that. The shred manual warns that some drive controllers may optimize all-zero writes, so it advises always including at least one random pass.

Overwrite Hard Drive with Zeros

Now you better occupy yourself with something time-consuming like Installing FOG Server or reading through some more awesome Open Source Tutorials, because this is gonna take a LONG time. Depending on the size of your Drive, it can take several hours to finish. For my 3 TB Drive, it will probably take around 10 Hours.

Once the procedure is finished, we have to format the Drive using GParted.

Step 3 - Format the Drive using Gparted

If you haven’t installed Gparted yet, first do that.

Terminalbash
sudo apt-get update -y
sudo apt-get install gparted

Run Gparted by typing:

Snippettext
gparted

Or simply via your Start Menu.

Overwrite Hard Drive with Zeros

Now make sure you select the correct Hard Drive from the Upper Right Corner. After that, select Device -> Create Partition Table. GParted defaults to msdos for drives under 2 TiB and gpt for larger ones, so my 3 TB Drive needs gpt.

How to Overwrite Hard Drive with Zeros

Next, right-click the unallocated space and select New. Choose NTFS as the Format and click Add.

Overwrite Hard Drive with Zeros

Now click on the Checkmark (or use Edit -> Apply All Operations) to Apply the operation. Don’t be confused by the File Size in the next Image, I had to continue this Tutorial on another Day and haven’t had the original Hard Drive at hand anymore.

Overwrite Hard Drive with Zeros

Once the Operation is finished, your Drive is cleanly formatted and ready to use! The screenshots show an older GParted, so your window may look a bit different.

FAQ

Does shred -z write only zeros?

No. shred -n1 -z writes one random pass and then a final pass of zeros. The -z option adds a zero pass after the random passes. For zeros only, use dd if=/dev/zero.

How long does overwriting a hard drive take?

It depends on the size and speed of the drive. A multi-terabyte hard disk takes hours, and my 3 TB drive needed around 10 hours. dd with status=progress shows the speed so you can estimate the rest.

Does this work on an SSD?

Not reliably. SSDs use wear levelling, so overwritten blocks can remain on the flash, and the shred manual says the same. Use ATA Secure Erase or nvme format instead, as described in the secure wipe guide.

Why do I have to format the drive afterwards?

After the wipe the drive holds no partition table and no file system. Create a new table and partition, for example in GParted, before you can store files on it.

Can shred destroy data on bad blocks?

Not always. The shred manual notes that if bad blocks hold sensitive data, shred may be unable to destroy it. For drives with known bad sectors, physical destruction is the safer route.

Conclusion

You see, it is really easy to Overwrite a Hard Drive with Zeros on Linux. Now you have completely wiped all Data from the Drive, and it is safe to use again.

whoami

Stefan founded Ceos3c in 2016 and has spent a decade teaching cybersecurity, Linux, and web development through hands-on tutorials. He builds and ships real products while sharing his journey: ProofSwap.me, XPMetric.com, and EasyEarningsTracker.com.

More about me

One thought on “Overwrite Hard Drive with Zeros on Linux: Fast & Easy!”

  1. The command you gave will actually overwrite the disk TWICE. The correct command would be: sudo shred -v -n0 -z /dev/sdX

Comments are closed. I keep the discussion here because the answers still help.