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 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 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 at 6:47

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 ATA devices, and your SSD is an NVMe device. That doesn't mean just a new connection type (like SATA) or the same 'disk' concepts in different terms (like SCSI/SAS) – instead it's a whole different kind of storage device entirely.

None of the ATA commands apply to NVMe (the general idea of "secure erase" is present, but it's implemented differently), and so nvme-cli was suggested to you because hdparm is simply the wrong tool for the job.

(At some point Linux used to support basic SCSI-NVMe command translation, but eventually removed it as the systems are just too different (unlike SCSI-ATA translation which is successfully used). Not that it would have helped you either way, as the features accessed by hdparm are very ATA-specific and aren't covered by the translation anyway. Even basic hdparm -i doesn't work on SCSI disks.)

  • 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 at 23:37
  • @Jack: I would hope that it uses the firmware built-in method, as the whole point of NVMe was to standardize the various PCIe SSD connection methods that manufacturers had... And the article I linked says that using the -s 1 option will request secure erase. – grawity Mar 9 at 9:40

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.