Linux – How to check if the ssd supports fstrim

fstrimlinuxssdtrim

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?

Best Answer

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.

Related Question