Jump to content
NotebookTalk

Secure Erase HDDs/SSDs(SATA/NVMe) using hdparm & nvme-cli on Linux


Vasudev

Recommended Posts

Hey everyone, I wanted to post a new thread dedicated for secure wiping SSD/HDDs after I tried hdparm and nvme-cli. I wasn't willing to share it initially, since it maybe dangerous if used incorrectly! Anyway, I posted this guide after searching many sources and made it as simple as possible! I've linked the sources at the end of the post. For images, I'm using Imgur so if anyone has any issues with images not loading or staying blank, please let me know!

I must warn everyone that incorrect name for example /dev/sdX can wipe out other drives, so backup.. backup... so as to prevent data loss. Don't hold me responsible for lost data.

For newbies, I'd recommend using Ubuntu ISO( I used Xubuntu distro) since it includes all necessary packages without needing to download anything from repos. For people who use other distros Gnome disk utility,gparted and nvme-cli packages are recommended to be installed for ease of use.

Don't forget to Backup your data before proceeding.

1. Open Gnome disk utility aka Disks and see the Disk name sdX you want to erase. My SSD is sdb, so I'm using /dev/sdb and yours might be different.

 
hdparm -I /dev/sdb

 

The output should look something similar to mine aside from terminal colors and background:

image.thumb.png.fce354500666df3ef8ac9c7c4b4083e9.png

 

2. If you see Frozen then you can Suspend the PC just to get rid off it when waking from Suspend state. The command is shown below:

 

image.png.9ffb36cbc28c1b86a80486d4ad95fde6.png

 

3. Once its woken from suspend/sleep mode you will see Not frozen when running hdparm -I /dev/sdX, subsitute X with your SSD or disk name.

4. You need to set a Password for Secure erase or Secure Erase enhanced to work. For the sake of simplicity, I'm using 'p' as a password and the command is:

hdparm --user-master u --security-erase p /dev/sdb

image.thumb.png.342c208436ec55b93c125d7c105896e2.png

 

5. Now lets secure erase SSDs, I'm using Secure SSD Enhanced since my drive supports it. It works for 2.5" SATA and M.2 SATA versions perfectly!

image.png.a3ab2366b3b2e59faf6ebcdbc82ff925.png

 

6. It will take under a minute to secure erase a SSD.
7. I re-initialised the SSD using gparted by using gpt as shown in the link here (optional step) I used it to create a fresh filesystem table so that HPA and other things are reset to defaults just like a new drive.

For NVMe drives:

8. Assuming nvme-cli package is installed, let's query list of NVMe installed in the system using:

sudo nvme list

 

image.thumb.png.7f61821f520cd5c757a582538cae3cd4.png

 

9. Follow Step 2 if you never suspended the Ubuntu or Linux LiveCD environment to un-freeze the disks.
10. Check if the NVMe drives support Secure erase or not: (As always if you've multiple NVMe disks choose appropriate name. If in doubt, check Gnome disk aka Disks or gparted for detailed info.)

nvme id-ctrl -H /dev/nvme0

 

Format NVMe support for basic formatting of NVME disk(s):
image.png.778fea6a370b8a684a7594570ad7b43b.png
Secure erase or crypto erase:
image.png.7fee39f438a0b67d932ee3141ea140d4.png
11. Format NVMe drive(s) with Secure Erase command:
Code:
nvme format /dev/nvme0 --ses=1
 
image.thumb.png.8a14bfe8a15de1c1827d71d40276164d.png

You will get a Success message or statement once NVMe secure erase is done, it takes a little more time than SATA so be patient! and once complete, follow Step 7 for best results.

 

Spoiler
Sources:
SATA SES:
https://grok.lsu.edu/article.aspx?articleid=16716

nvme secure erase:

http://blog.pythonaro.com/2018/05/how-to-securely-wipe-nvme-drive.html
https://tinyapps.org/docs/nvme-secure-erase.html
https://github.com/linux-nvme/nvme-cli/blob/master/Documentation/nvme-format.txt
https://www.mankier.com/1/nvme-format

 

image.png

  • Thumb Up 4
Link to comment
Share on other sites

  • 2 months later...

good guide bud, ive personally been using parted magic in a live ram environment via usb stick to properly reset my ssds every once in a while. helps keep them fresh performanse-wise!

  • Thumb Up 1

Mine: Hyperion "Titan God of Heat, Heavenly Light, Power" (2022-24)
AMD Ryzen 9 7950X (TG High Perf. IHS) / Asus ROG Crosshair X670E Extreme / MSI Geforce RTX 4090 Suprim X / Teamgroup T-Force Delta RGB DDR5-8200 2x24 GB / Seagate Firecuda 530 4 TB / 5x Samsung 860 Evo 4 TB / Arctic Liquid Freezer II 420 (Push/Pull 6x Noctua NF-A14 IndustrialPPC-3000 intake) / Seasonic TX-1600 W Titanium / Phanteks Enthoo Pro 2 TG (3x Arctic P12 A-RGB intake / 4x Arctic P14 A-RGB exhaust / 1x Arctic P14 A-RGB RAM cooling) / Samsung Odyssey Neo G8 32" 4K 240 Hz / Ducky One 3 Daybreak Fullsize Cherry MX Brown / Corsair M65 Ultra RGB / PDP Afterglow Wave Black / Beyerdynamic DT 770 Pro X Limited Edition

 

My Lady's: Clevo NH55JNNQ "Alfred" (2022-24)
Sharp LQ156M1JW03 FHD matte 15.6" IGZO 8 bit @248 Hz / Intel Core i5 12600 / Nvidia Geforce RTX 3070 Ti / Mushkin Redline DDR4-3200 2x32 GB / Samsung 970 Pro 1 TB / Samsung 870 QVO 8 TB / Intel AX201 WIFI 6+BT 5.2 / Win 11 Pro Phoenix Lite OS / 230 W PSU powered by Prema Mod!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use