I installed an SSD but I can’t verify TRIM is functioning.

MY SSD is working but TRIM may not be.

I’m running Fedora 36 with BTRFS. I installed a Samsung SSD 980 PRO 2TB SSD firmware version 5B2QGXA7 as a secondary drive that does not auto mount, as intended. I have the drive set as LUKS Encrypted. Everything appears to work, unlock, mount, unmount, lock, as intended.

Running fstrim produces:

the discard operation is not supported

I tried using hdparm to verify the NVME drive supports TRIM but got odd results. I’ve been told that hdparm does not support NVME devices.

mount shows:

/dev/mapper/luks-ffb768b8-144c-4250-8eb7-17f11cc7367c on /run/media/xxxxx/SSD-1 type btrfs (rw,nosuid,nodev,relatime,seclabel,ssd,space_cache=v2,subvolid=5,subvol=/,x-gvfs-show)

Is TRIM functioning, and if not how do I fix it?


1 Like

What’s the output of

ls -la  /sys/block/[v,s,n]*/queue/discard_max_bytes

cat /sys/block/[v,s,n]*/queue/discard_max_bytes

ls -la /sys/block/[v,s,n]*/queue/discard_max_bytes
-rw-r–r–. 1 root root 4096 May 21 16:55 /sys/block/nvme0n1/queue/discard_max_bytes
-rw-r–r–. 1 root root 4096 May 21 16:55 /sys/block/sda/queue/discard_max_bytes
-rw-r–r–. 1 root root 4096 May 21 16:55 /sys/block/sdb/queue/discard_max_bytes
-rw-r–r–. 1 root root 4096 May 21 16:55 /sys/block/sr0/queue/discard_max_bytes

cat /sys/block/[v,s,n]*/queue/discard_max_bytes

Have you enabled discard support when unlocking your LUKS device? See dm-crypt/Specialties - ArchWiki .

I use the gnome-disk-utility GUI for unlocking and mounting.

The Unlock options are: “nofail,discard”

The mount options are: “nosuid,nodev,nofail,x-gvfs-show,discard”

I’ve also tried “async” instead of “discard”.

sudo cat /etc/crypttab
luks-55aa2d74-c7f5-4991-926b-789671311fbf UUID=55aa2d74-c7f5-4991-926b-789671311fbf none discard
luks-c1a5b64d-1c16-4f36-bd7f-abf8fb2d1bf9 UUID=c1a5b64d-1c16-4f36-bd7f-abf8fb2d1bf9 none discard
luks-ffb768b8-144c-4250-8eb7-17f11cc7367c UUID=658fc285-ff11-4c22-8d7b-5b09dd67e0a3 none discard
luks-ffb768b8-144c-4250-8eb7-17f11cc7367c UUID=ffb768b8-144c-4250-8eb7-17f11cc7367c none nofail,discard

Where “luks-ffb768…” is the SSD and “UUID=658fc…” is the mounted unencrypted partition.

> lsblk --discard
> nvme0n1            0     512B       2T      0
> └─nvme0n1p1       0           512B    2T    0
>   └─luks-ffb768b8-144c-4250-8eb7-17f11cc7367c      0   0B   0B    0

Seems to suggest that the physical SSD supports TRIM, but not the luks volume.


Command line manual unlock:

sudo cryptsetup luksOpen --allow-discards /dev/nvme0n1p1 ssd_partition

sudo lsblk --discard

> nvme0n1                  0      512B       2T         0
> └─nvme0n1p1         0      512B       2T         0
>   └─ssd_partition      0      512B       2T         0

It looks like TRIM may work now?

It Does!

So it would appear to be related to gnome-disk-utility unlock.

I have something to work with now, YAY!

See the linked article on how to make the allow-discards flag permanent for your LUKS device, so that you can continue unlocking from gnome-disks, if desired.

Thank you! :smiley:

I was unable to to find a direct gnome-disk-utility option to make it work. However:

Manually unlocking from the command line once with:

sudo cryptsetup luksOpen --allow-discards --persistent /dev/nvme0n1p1 ssd-1_partition

Resolved the issue.

The –persistent option wrote the –allow-discards into the metadata. Now gnome-disk-utility simply works and TRIM is enabled.

Thank you again!