How to Completely Wipe Your Hard Drive in Linux

You may have sold your old computer after a recent upgrade and need to ensure that your personal photos are not displayed on the Internet. You may have many reasons for wanting to erase data from your hard drive or SSD. Unfortunately, the process is a far cry from what we’ve seen in Hollywood movies: you can’t press the knob and delete everything in seconds.

However, with a little patience and issuing commands on the terminal or the correct live CD, you can erase a complete hard drive or SSD, making it difficult, if not impossible, for third parties to retrieve data.

Secure erase vs storage

Secure Erase is a feature that completely erases the contents of a storage device. It has become part of most HDD and SSD firmware and is the recommended solution for safe removal. But in fact, some users have reported serious complications.

The implementations of different vendors seem to be different, and sometimes the data cannot be completely deleted.

Others say that its operation “bricks up” the device, because “the controller that converts it from an internal device to an external device” decided that it would be a good idea to reduce its electricity bill through sleep. Or because of incomprehensible BIOS errors that “blocked the way” in some way and prevented the process from completing.

And (many) older hard drives (less than 15GB in size) just don’t support it.

Therefore, the “official and best” method of secure erasure is still a bit risky, which makes the choice of alternatives much better. Therefore, we will skip it and jump directly to a safer alternative.

Overwrite data

When files are deleted in modern operating systems, they are usually transferred to the Recycle Bin. If we change our mind, we can still recover any data for a period of time.

It can be assumed that “complete” deletion, rather than moving files to the Recycle Bin, is a safer method. However, the file is still not eliminated: the media controller marks the area occupied by the file as “free to use”, but the data contained in it remains unchanged.

Deleting the entire partition and file system sounds like a better choice, but it sounds more thorough until you realize it’s the same thing, but on a larger scale. The entire partition was “marked as non-existent” and the space it covered was marked as “unused”, but nothing was really erased. The data will persist until it is overwritten.

The only reliable way to delete sensitive data is to overwrite it with other data. Preferably, more than once. This is the effect of the following method. They differ in their usability, ease of use, and additional options for more secure removal by using multiple overlays and modes.

What will you delete?

If you have multiple storage devices on your PC, you need to know what it is before trying to delete anything to avoid “unfortunate” things like clearing the wrong disk.

The easiest path is if you are already in a graphical user environment with the HDD / SSD you want to remove connected as a secondary device. You can then use a program like GParted to check out all storage devices and determine the correct storage device.

Linux remove HDD install Gparted

If you prefer the terminal, you have more options. Some may already be part of your distribution. Others may need to install additional tools.

Lsblk Lets you view all blocking devices connected to your computer. For clear results, try the following:


smartctl Lets you view information about each device. Use it like this:

smartctl -i /dev/sdX

A bit difficult to understand, but it is also helpful, hdparm Comparable results can be displayed using almost the same commands:

hdparm -i /dev/sdX

At last, fdisk It is probably the most popular option and is usually installed in almost all Linux distributions. It can also display information about drives and SSDs, although not as detailed as the other options. Try using:

fdisk -l

dd method

Once you find a device with the content you want to destroy, you can use a command to overwrite this data “other way,” making it almost impossible to retrieve. The order and this “other” content will be a priority.

Linux clear HDD Dd

The most common method is to use pop dd Command the following tools:

dd if=/dev/zero of=/dev/sdX

inside, of=/dev/sdX Corresponds to the device to be erased, such as of=/dev/sda Either of=/dev/sdc.

You can speed up the process by using chunks and see a progress summary by structuring it into the following:

dd if=/dev/zero of=/dev/sdX bs=4096 status=progress

Where bs=4096 Is the block size, which varies from device to device, and ideally you can find the block size that fits your device on the manufacturer’s website. Status=progress You are required to have a progress indicator that will show the time before completion.

Linux clear Hdd Dd Urandom

Using a random pattern rather than a uniform zero set is considered more secure and can delete unrecoverable data. You can do this by using alternate commands for these commands:

dd if=/dev/urandom of=/dev/sdX bs=4096 status=progress

As you can see, we use another source, replacing zero with a random number. Note that this method increases the utilization of system resources because it generates task CPUs with a constant random number.

Scrub method

Frosting is another option that is easier to implement in practical use, but the syntax is simpler.

Linux clear HDD install Scrub

Scrub is usually not installed in most Linux distributions, you may have to install it first with:

sudo apt install scrub

After installation, to completely remove any HDD or SSD simply enter the following as root:

scrub /dev/sdX

Wipe everything

Similar to scrub wipe Easily and annoyingly erase the contents of a storage device-check it carefully before putting it on your valuable data. Just like scrub, to use wipe in most Linux distributions, you first need to install it.

sudo apt install wipe

Linux Erase HDD Erase

Then, to erase everything in sdX, just press Enter after typing in the terminal:

wipe /dev/sdX

Real-time GUI path

note: Regardless of the operating system running on your hard drive, the following methods will work.

If you want to destroy the contents of the HDD or SSD where the OS is located, you cannot do so while using the OS. Instead, you can use a Linux distribution’s Live CD / DVD-preferably a distribution using the Gnome desktop environment, which usually comes with an easy-to-use Gnome disk utility.

To delete everything this way, boot from the release’s Live CD / DVD. Run the Gnome Disk Utility (found as “Disk” in Gnome).

Linux HDD Gnome Disk Utility

Select the storage you want to delete from the list in the left pane, click the two buttons, and select Format Partition.

In the window that appears, enable the “Erase” option to overwrite the existing data.

Enter the name of the storage medium in “Volume Name”, click “Next” in the upper right corner, and click the “Format” button that will be displayed in the same location again to accept the warning displayed.

Dariq’s Boot and Nuke Solution

Another method, also based on real-time CD, relies on “Darik’s Boot and Nuke”, or DBAN. DBAN is a stand-alone bootable tool, not a standard distribution, and it’s dedicated to a separate process: completely removing everything from HDD or SSD.

Linux clear Hdd Dban

After starting the computer from the computer, and after the initial process of identifying the computer hardware, DBAN will show you a list of found devices. Use the cursor keys to select the one you want to erase, then enter or press space and press F10 to start the deletion process.

Best results: hammer and ammunition

We are not data recovery experts, so we cannot guarantee which method performs better. Some claim that special equipment can be used to detect and recover data traces from the hard drive surface that have been overwritten twice. Others insist that this is theoretical, and there is no evidence that it is feasible. Some recovery companies claim that they have even saved data from hard drives that have almost collapsed in the fire or have broken disks.

Since they are experts and will introduce these situations with some of the worst, it is best to convince them: the introduction of the hammer and Elon Musk’s Not-a-Flamethrower sound like the most powerful “safe removal” . But for those of us who ca n’t use a flamethrower and do n’t like to pose as Sol at 3 am, the method we saw was the best option.