8

I'm trying to use hdparm to do secure erase of my 512GB SSD SK Hynix. SSD has Windows 10 installed in it.

I boot Ubuntu from a usb flash drive.

sudo fdisk -l

I get a lot of different disks, turns out /dev/sda is my 8gb flash drive, not SSD.

SSD is listed as:

Disk /dev/nvme0n1: 477 GiB, 512110190592 bytes, 1000215216 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt

Now when I try to run: hdparm -I /dev/nvme0n1 terminal gives me error: "/dev/nvme0n1: HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device"

how do I use hdparm secure erase option on my SSD? From suggestion in another page on the internet, nvme-cli package was suggested, but I don't understand how that helps.

using shred command isn't recommended for SSD because SSD has limited read/write cycles, and it works very differently than HDD.

Update: my SSD is an NVMe device, not ATA, therefore hdparm command isn't suitable, use nvme -format instead.

  • I find gnome-disks is much easier to interact with and understand by clearly showing containers vs. contents. It also makes it easy to mount a partition to verify its contents. – wallyk Mar 8 '19 at 19:04
  • @wallyk what does it have to do with what OP-post is asking? Anyhow, does it mean that because my SSD uses PCI-E or whatever, I can't use hdparm? Do I have to use nvme command to do secure erase? – Jack Mar 8 '19 at 19:22
  • Aren't you the OP? (That's confusing.) Anyway, I suspected you were having trouble identifying the correct drive/partition to operate on. – wallyk Mar 9 '19 at 6:47
7

To erase an NVMe device using nvme-cli, run nvme format -s1 <device>.

nvme-cli package was suggested, but I don't understand how that helps.

hdparm works exclusively with devices which speak the ATA protocol, but your SSD is built to speak the NVMe protocol.

That difference is not limited to just physical connection (like IDE/SATA) – instead the OS has to use an entirely different set of commands when communicating with the device. None of the ATA commands apply to NVMe (the general idea of "secure erase" is present, but it's implemented differently).

Therefore nvme-cli was suggested to you because hdparm is the wrong tool for the job from the very beginning.


In theory, it would be possible for an OS to translate between the command sets (intercept ATA commands and issue equivalent NVMe commands), and indeed the Linux kernel internally does this to some extent for SCSI-to-ATA. At some point, Linux even used to support basic SCSI-to-NVMe translation, but this was eventually removed as the systems are just too different.

However, it wouldn't have helped you because Linux doesn't do it the other way around: you already can't use the ATA-specific hdparm against SCSI disks, and likewise you wouldn't have been able to use hdparm against NVMe disks.

| improve this answer | |
  • nvme command uses the firmware built-in method, are there third party methods that do secure erase SSDs on their own? Or it's impossible because the way the data is written onto SSD varies by manufacturer? Also, it looks like this nvme -format only partitions meta data, like it's not actually secure erase, is it true? – Jack Mar 8 '19 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.