1

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.

My concern revolves around TRIM.

Running fstrim produces:

the discard operation is not supported

In my efforts to make sure discards is enabled everywhere I checked to make sure it was supported with hdparm. This really confused me!

sudo hdparm -I /dev/nvme0n1

/dev/nvme0n1:

Nothing?

sudo hdparm -i /dev/nvme0n1

/dev/nvme0n1:
 HDIO_GET_IDENTITY failed: Inappropriate ioctl for device

and

sudo hdparm /dev/nvme0n1

/dev/nvme0n1:
 readonly      =  0 (off)
 readahead     = 256 (on)
 geometry      = 1907729/64/32, sectors = 3907029168, start = 0

So now I'm wondering if this is a Samsung issue?

I'm not sure where to go from here?

EDIT

I've been told that hdparm does not support NVME, only SATA.

user10216038
  • 313
  • 1
  • 7
  • No expert on this. Does this help / answer the question: https://wiki.archlinux.org/title/Dm-crypt/Specialties#Discard/TRIM_support_for_solid_state_drives_(SSD) – Joep van Steen May 20 '23 at 19:51
  • @Joep van Steen - Thanks for the thought. I've tried variants of that without sucess, that's why I went directly to HDPARM to verify the SSD supports TRIM and got weird results. – user10216038 May 21 '23 at 05:40
  • Probably not help, but I would run `smartctl -x /dev/nvme0n1` and see what it says. – Bib May 21 '23 at 09:46
  • @Bib - Good thought, everything looks normal, no errors. Nothing about TRIM. – user10216038 May 21 '23 at 16:14

1 Answers1

1

I have it working now. It turns out I left off a key piece of information I didn't know was pertinent. So for anyone else:

I was using the GUI gnome-disk-utility for unlocking and mounting the encrypted partition.

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 LUKS2 header metadata. Now gnome-disk-utility simply works and TRIM is enabled.

See ArchLinux TRIM Support

How to test if TRIM is enabled:

sudo lsblk --discard   
NAME                                           DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
     nvme0n1                                        0    512B      2T       0
     └─nvme0n1p1                                    0    512B      2T       0 
       └─luks-ffb768b8-144c-4250-8eb7-17f11cc7367c  0    512B      2T       0

The third entry will be missing or zeros if TRIM is not enabled.

user10216038
  • 313
  • 1
  • 7