4

I'm working with a linux server and wanted to know if there is a way that I can find out that my SSD supports fstrim or not. I tried hdparm -I /dev/sda, but it's not available and I can't install it. Is there any other way I can do it? Any help is appreciated. Thanks!

I'm also curious to know what happens if I run fstrim on a device that doesn't support trim? Does it result in a no-op?

1

You may also try lsblk --discard

Non-zero values under DISC-GRAN and DISC-MAX indicate trim support.

$ lsblk --discard
NAME          DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
nvme0n1              0      512B       2T         0
├─nvme0n1p1          0      512B       2T         0
├─nvme0n1p2          0      512B       2T         0
├─nvme0n1p3          0      512B       2T         0
└─nvme0n1p4          0      512B       2T         0
  └─cryptswap        0        0B       0B         0

Ensure your disk is trim compatible before running fstrim. Running fstrim on an SSD that does not provide trim support can result in data loss. For reference, see the Arch Wiki.

0

Try

find /sys/devices -name trim -exec head {} +

... 
==> /sys/devices/pci0000:00/0000:00:11.0/ata3/link3/dev3.0/ata_device/dev3.0/trim <==
unsupported
-1

Every SSD made in the past decade supports trim/discard. If it isn't supported, the command should just fail and not do anything. I say "should" because if you really have an SSD without trim it is of such poor branding lineage that the disk firmware quality is an extreme unknown quantity.

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.