How to Permanently Erase Hard Drive with Secure Erase and Make Data Unrecoverable
Understand how file deletion actually works, then learn how to permanently wipe a hard drive with Secure Erase. Includes troubleshooting if the process gets interrupted.
Deleted Files Are Recoverable
Computers are 0s and 1s. Truly deleting a file would mean overwriting every bit of data with zeros (0x00000000…). If you deleted a 2 GB video, the system would have to write zeros across the entire file, a process that would be incredibly slow. Instead, computers simply mark the file as deleted and make that space available for new data.
Your phone works the same way. When you delete a photo, it’s marked as hidden and its space opens up for new content. The difference is that your photos are encrypted with a secret key. When you format your phone, that key gets deleted. The photo data is still there, but it’s unreadable without the key.
Databases and cloud storage follow the same principle. At my previous company, when users deleted their accounts, I marked them as inactive instead of removing them entirely in database. This approach was faster, safer, and easier to restore if needed.
Because deletion only marks data as unavailable rather than erasing it, deleted files can often be recovered. Here’s how to permanently wipe a hard drive.
Step 1: Check if the drive supports Secure Erase
sudo hdparm -I /dev/sda | grep -A10 "Security:"
Replace /dev/sda with where your drive is mounted on. You need to see supported in the output.
Step 2: Verify the security state
Look for these in the output:
not enablednot lockednot frozen
Step 3: Enable the security featrue by setting a password
sudo hdparm --user-master u --security-set-pass p /dev/sda
This sets password p and enables the security feature. Use p as password.
Step 4: Verify the security feature is now enabled
sudo hdparm -I /dev/sda | grep -A10 "Security:"
Now it should say enabled instead of not enabled.
Step 5: Erase and drive
sudo hdparm --user-master u --security-erase p /dev/sda
Use the same password (p) you just set. The drive will wipe itself completely. This may take several hours depending on drive size.
If your computer shuts down or the drive disconnects during secure erase, the drive will lock up and become unusable. To unlock it, run:
sudo hdparm --security-disable "p" /dev/sda
This disables the security lock using password p. Then you can restart the secure erase.
