15

With a non-NVMe drive, I can run:

# hdparm -I /dev/whatever | grep TRIM
Data Set Management TRIM supported (limit 8 block)
Deterministic read data after TRIM

With a Samsung 960 EVO 1TB NVMe drive (PCI Express), I get:

# hdparm -I /dev/nvme0n1
/dev/nvme0n1:
 HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device

I can run

# smartctl --all /dev/nvme0n1

And get some information about the drive, but nothing about TRIM type.

I installed nvme-cli, and ran nvme get-feature -f 0 to -f 0xe and got some features from the drive, but nothing about TRIM type.

Is there a way in Linux to query an NVME device, to list what type of TRIM it supports?

Is there a way in Linux to query an NVMe device, to get a list of anything else hdparm -I would show if it weren't an NVMe, that smartctl and nvme don't seem to cover?

2 Answers 2

7

I understand that TRIM is equivalent to NVME Data Set Management (DSM) Deallocate. If it is supported, it can be applied to 256 regions up to 16 blocks in size each.

Check id-ctrl command oncs.bit2 if it is supported.

# nvme id-ctrl /dev/nvme1 -H
oncs    : 0x6
  [5:5] : 0 Reservations Not Supported
  [4:4] : 0 Save and Select Not Supported
  [3:3] : 0 Write Zeroes Not Supported
  [2:2] : 0x1   Data Set Management Supported
  [1:1] : 0x1   Write Uncorrectable Supported
  [0:0] : 0 Compare Not Supported

These commands can give you more information about the nvme device:

nvme id-ctrl /dev/nvme0 -H
nvme id-ns /dev/nvme0n1 -H
nvme show-regs /dev/nvme0n1 -H
1

To answer OP's question (what type of TRIM it supports), first of all, all conforming NVME disks should be at least DRAT (Deterministic Read After Trim).

Here's a quote from chapter 3.2.3.2.1 Deallocated or Unwritten Logical Blocks in NVM Express® NVM Command Set Specification revision 1.0c October 3rd, 2022.

The value read from a deallocated logical block shall be deterministic; specifically, the value returned by subsequent reads of that logical block shall be the same until a write operation occurs to that logical block.

To know what value your disk's trimmed blocks read, execute a command like this:

# nvme id-ns /dev/nvme0n1 -H | grep -A 4 "dlfeat"
dlfeat  : 1
  [4:4] : 0     Guard Field of Deallocated Logical Blocks is set to 0xFFFF
  [3:3] : 0     Deallocate Bit in the Write Zeroes Command is Not Supported
  [2:0] : 0x1   Bytes Read From a Deallocated Logical Block and its Metadata are 0x00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .