Skip to content

SSDs / NVMEs

NVME disks

NVME drive

nvme list
nvme smart-log /dev/nvme0n1
nvme wdc help

Format nvme disk

Sanitize / Secure-erase

Arch wiki: Solid_state_drive/Memory_cell_clearing: NVMe_drive

Show available commands for the drive:

nvme id-ctrl /dev/nvme0 -H | grep -E 'Format |Crypto Erase|Sanitize'

Sanitize:

nvme sanitize-log /dev/nvme0

When the Sanitize command is not supported proceed with format:

nvme format /dev/nvme0nX -s 1

NVME smart

Show percent_used (aka wear levelling):

sudo nvme smart-log /dev/nvme0n1 --output-format=json | jq .percent_used

SSDs

Discard / fstrim

tldr:

  • Discard is already added during installation in /etc/crypttab
  • The system timer fstrim.timer is also enabled during installation
  • Don't enable discard in /etc/fstab !
  • Add discard option to luks devices in /etc/crypttab
  • LVM has issue_discards already set by default
  • A systemd timer + service (fstrim.timer) is enabled by default already systemctl status fstrim.timer

Show trimming results: systemctl status fstrim.timer

Secure Erase

Make sure disk is not frozen:

sudo hdparm -I /dev/sdX | grep frozen

Set dummy user pw:

sudo hdparm --user-master u --security-set-pass 1234 /dev/sdX

Ensure security (pw) is enabled:

sudo hdparm -I /dev/sdX | grep -B3 enabled

Erase:

time sudo hdparm --user-master u --security-erase 1234 /dev/sdX

Takes up to ~12s for 500gb SSD.

Ensure security (pw) is not enabled anymore:

sudo hdparm -I /dev/sdX | grep -B3 enabled