How to *secure erase* a NVMe SSD

9,712

Solution 1

To totally erase a NVMe drive.

This will erase entire drive.

You may need to first install nvme - the NVMe storage command line interface utility (nvme-cli). Then review commands and list all nvme devices. List wil also show firmware revision & you should check that you have latest firmware.

sudo apt install nvme-cli
nvme help
nvme --help
nvme --help format
sudo nvme list
sudo nvme format -s1 <device>

    fred@z170-focal-k:/mnt/data$ sudo nvme list
[sudo] password for fred: 
Node             SN                   Model                                    Namespace Usage                      Format           FW Rev  
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1     S4P2NF0M514514L      Samsung SSD 970 EVO Plus 500GB           1         164.30  GB / 500.11  GB    512   B +  0 B   2B2QEXM7

Solution 2

For resetting to Out Of Box performance you DO NOT want to use the "write zeroes" technique of dd/fio. There is a BIG semantic difference saying "this area must contain and maintain zeroes" (fio/dd technique) and saying "this area is must be empty" (secure erase). For example the Solid State Storage (SSS) Performance Test Specification (PTS) specifies techniques it considers reasonable for preconditioning.

Share:
9,712

Related videos on Youtube

Tim He
Author by

Tim He

Updated on September 18, 2022

Comments

  • Tim He
    Tim He over 1 year

    Since SSD has write amplification, I want to reset the SSD to the initial out-of-box performance. Most tutorials are for SATA SSD (hdparm --secure-erase), I want to know how to erase a partition of NVMe SSD (maybe use nvme command?).

    One more question: does dd if=/dev/zero of=/dev/nvme0n1 help? Or does fio --filename=/dev/nvme1n1 --direct=1 --buffered=0 --rw=trim --bs=4k --size=100G --numjobs=16 --iodepth=32 --group_reporting --name=trim help?

    Thanks!

    • oldfred
      oldfred over 3 years
      One partition or entire device? See nvme help & then nvme help format I have in my notes this but never used it. It will erase entire drive. sudo nvme format -s1 <device> To see devices: sudo nvme list
    • Tim He
      Tim He over 3 years
      sudo nvme format -s1 <device> works! Thanks for the help.
    • Ciro Santilli OurBigBook.com
      Ciro Santilli OurBigBook.com almost 3 years
  • Brad
    Brad over 2 years
    How long should this secure erase take? I tried doing this and got Success formatting namespace:1 after only about 2-3 seconds. It seems way too fast for a 480 GB drive.
  • Craig S. Anderson
    Craig S. Anderson over 2 years
    In general, securely erasing an SSD does not involve writing every bit, which would take a long time. And the NVME standard has secure erase built in, so the drive maker (presumably) made this very fast.