The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

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

    Discussion in 'Hardware Components and Aftermarket Upgrades' started by Vasudev, Feb 15, 2019.

  1. Vasudev

    Vasudev Notebook Nobel Laureate

    Reputations:
    12,035
    Messages:
    11,278
    Likes Received:
    8,814
    Trophy Points:
    931
    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.
    Code:
    hdparm -I /dev/sdb
    • The output should look something similar to mine aside from terminal colors and background:
    [​IMG]
    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:
    [​IMG]
    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:
    Code:
    hdparm --user-master u --security-erase p /dev/sdb
    [​IMG]
    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!
    [​IMG]
    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:
    Code:
    sudo nvme list

    [​IMG]
    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.)
    Code:
    nvme id-ctrl -H /dev/nvme0

    Format NVMe support for basic formatting of NVME disk(s):
    [​IMG]
    Secure erase or crypto erase:
    [​IMG]
    11. Format NVMe drive(s) with Secure Erase command:
    Code:
    nvme format /dev/nvme0 --ses=1

    [​IMG]
    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.

    @hmscott @Papusan @jclausius @Dennismungai @Mr. Fox @jaybee83 @VICKYGAMEBOY @judal57 Ultra Male @Dr. AMK @tilleroftheearth @GreatD @rinneh @ssj92 and others...

    Sources:
    Code:
    [/SIZE][/SIZE][/SIZE][/SIZE]
    [SIZE=5][SIZE=4][SIZE=5][SIZE=4]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


    Don't forget to Backup your data. Don't say I didn't warn you!
     
    Last edited: Apr 19, 2019
    steberg, Papusan, jaybee83 and 5 others like this.
  2. Mr. Fox

    Mr. Fox BGA Filth-Hating Elitist

    Reputations:
    37,213
    Messages:
    39,333
    Likes Received:
    70,629
    Trophy Points:
    931
    Vasudev and jclausius like this.
  3. Dennismungai

    Dennismungai Notebook Deity

    Reputations:
    785
    Messages:
    933
    Likes Received:
    867
    Trophy Points:
    106
    Awesome, thanks!
     
    Vasudev, jclausius and Mr. Fox like this.
  4. jclausius

    jclausius Notebook Virtuoso

    Reputations:
    6,160
    Messages:
    3,265
    Likes Received:
    2,573
    Trophy Points:
    231
    Agreed. Kudos!!
     
    Vasudev and Mr. Fox like this.
  5. Vasudev

    Vasudev Notebook Nobel Laureate

    Reputations:
    12,035
    Messages:
    11,278
    Likes Received:
    8,814
    Trophy Points:
    931
    Thanks everyone. Well, I did try to erase my non-backup'ed drive by copy and pasting the same cmds, you'll see in Step 5 where I accidetally hit Enter key and cmd was issued! Fortunately, HDD/SSD were Frozen so those cmds failed. That's why I highlighted Backup important data.
    A minor mistake might wipe out the data.
    My guide isn't as good looking as Ultra Male's post.
     
    jaybee83 and jclausius like this.
  6. Vasudev

    Vasudev Notebook Nobel Laureate

    Reputations:
    12,035
    Messages:
    11,278
    Likes Received:
    8,814
    Trophy Points:
    931
    @Charles P. Jefferies This thread is similar to Ultra Male's SSD erase guide, but involves lot of manual work using the same internal working of Parted Magic and most Linux distros in a freeware.
     
  7. Mr. Fox

    Mr. Fox BGA Filth-Hating Elitist

    Reputations:
    37,213
    Messages:
    39,333
    Likes Received:
    70,629
    Trophy Points:
    931
    It's good to have your post/thread here because Parted Magic is more of a point and click experience designed for Windows users and you presented how one would do this using Linux with terminal commands. I actually like using a command line interface. It took me a long time to accept using a Windows GUI and I preferred using DOS (and primarily used DOS as much as possible) until about half way through the life cycle of Windows 98. I never actually liked Windows 3.X or Windows 95, and didn't fully embrace it until Windows XP.
     
  8. Vasudev

    Vasudev Notebook Nobel Laureate

    Reputations:
    12,035
    Messages:
    11,278
    Likes Received:
    8,814
    Trophy Points:
    931
    Uses the same thing but presented in a nice GUI. Its more bleeding edge than LTS. I always like CMD lines or xterm. I still play dosgames on my PC at ultra pixelated graphics at VGA resolution.
     
  9. Vasudev

    Vasudev Notebook Nobel Laureate

    Reputations:
    12,035
    Messages:
    11,278
    Likes Received:
    8,814
    Trophy Points:
    931
    @Charles P. Jefferies Can you change title of the thread to "
    Secure Erase HDDs/SSDs(SATA/NVMe) using hdparm & nvme-cli on Linux"
     
    Charles P. Jefferies likes this.
  10. custom90gt

    custom90gt Doc Mod Super Moderator

    Reputations:
    7,907
    Messages:
    3,862
    Likes Received:
    4,808
    Trophy Points:
    331
    Done, you can always report your post and ask for a title change.
     
  11. Vasudev

    Vasudev Notebook Nobel Laureate

    Reputations:
    12,035
    Messages:
    11,278
    Likes Received:
    8,814
    Trophy Points:
    931
    Ok I thought it was for reporting abuse and offensive posts!
    I will keep it in mind.
     
    custom90gt likes this.
  12. Vasudev

    Vasudev Notebook Nobel Laureate

    Reputations:
    12,035
    Messages:
    11,278
    Likes Received:
    8,814
    Trophy Points:
    931
    Any refinements needed or what? I hope every step is easy to follow.
     
  13. Dennismungai

    Dennismungai Notebook Deity

    Reputations:
    785
    Messages:
    933
    Likes Received:
    867
    Trophy Points:
    106

    It's perfect.

    I have sanitized a couple of WD Blue NVMe SSDs (part number WDS100T2X0C) with these instructions and they work well.
    Caution is still advised when using device names (/dev/nvme*) etc as using the wrong path will erase the wrong drives.
     
    jclausius, Vasudev and Papusan like this.
  14. Vasudev

    Vasudev Notebook Nobel Laureate

    Reputations:
    12,035
    Messages:
    11,278
    Likes Received:
    8,814
    Trophy Points:
    931
    2 weeks ago I used my guide because I forgot all the damn commands for NVMe Protocol to clean install 19H1, so far so bad on 19H1, Hahaa... Looks like I will switch to Linux next year!
     
  15. 6.|THE|1|BOSS|.9

    6.|THE|1|BOSS|.9 Notebook Evangelist

    Reputations:
    915
    Messages:
    498
    Likes Received:
    970
    Trophy Points:
    106
    I will be on the same path as you.. next year will be Linux year :D
     
    Vasudev likes this.
  16. Vasudev

    Vasudev Notebook Nobel Laureate

    Reputations:
    12,035
    Messages:
    11,278
    Likes Received:
    8,814
    Trophy Points:
    931
    Yeah full time Linux is wonderful idea and windows 10 will be used for MS office and some gaming/benching.
     
    6.|THE|1|BOSS|.9 likes this.
  17. TANWare

    TANWare Just This Side of Senile, I think. Super Moderator

    Reputations:
    2,548
    Messages:
    9,585
    Likes Received:
    4,997
    Trophy Points:
    431
    My primary concern with a Linux only system is because of the sandbox the browser will not pass info to java apps and visa versa. I use this function lot with e-trade so it keeps me in a Windows machine.

    I would get a bigger SSD for the Huawei and run Linux but the above keeps me from doing so. I do not really care for using it to game but would also keep windows for when M$ Office is absolutely required only, open office would suffice for most other times.
     
    Vasudev likes this.
  18. Suncatcher

    Suncatcher Notebook Enthusiast

    Reputations:
    0
    Messages:
    31
    Likes Received:
    6
    Trophy Points:
    16
    Thanks a lot, this guide really helped me. The only thing to add is that all nvme commands should be run through sudo.

    Sent from my Redmi 7 using Tapatalk
     
    Vasudev likes this.
  19. Vasudev

    Vasudev Notebook Nobel Laureate

    Reputations:
    12,035
    Messages:
    11,278
    Likes Received:
    8,814
    Trophy Points:
    931
    I did that intentionally to prevent users from blindly erasing SSDs or HDDs by giving wrong drive paths.
    I'm glad the guide helped you!
     
  20. Suncatcher

    Suncatcher Notebook Enthusiast

    Reputations:
    0
    Messages:
    31
    Likes Received:
    6
    Trophy Points:
    16
    BTW while checking drive params, I noticed my SSD also has secure-erase disabled. Are there many SSDs with this feature on the market?

    Sent from my Redmi 7 using Tapatalk
     
    Last edited: Feb 21, 2020
  21. Vasudev

    Vasudev Notebook Nobel Laureate

    Reputations:
    12,035
    Messages:
    11,278
    Likes Received:
    8,814
    Trophy Points:
    931
    I think 95% of SSD sold in the market support Secure Erase protocol.
     
    Suncatcher likes this.