gitbls / sdm

Raspberry Pi SD Card Image Manager
MIT License
469 stars 48 forks source link

satrim trim-enable: Cannot find /sys/block/nvme0n1 #165

Closed dantchapman closed 9 months ago

dantchapman commented 9 months ago

Thank you for providing the satrim script - I have used in in my pi4 machines.

I was trying to repeat the same on my pi5 with an nvme disk attached. The following error resulted:

There is an SSD attached to USB (sda) and also an nvme attached via pci. I'm in the process of migrating from the external ssd to the 'internal' nvme.

Is this because the nvme drive is being misinterpreted in some way?

note that fstrim -v reports no errors when trimming a mounted directory.

gitbls commented 9 months ago

Amusingly, I just ordered an NVME adapter and disk, so would have run into this myself this week.

Once I can get hands-on with some NVME hardware I'll get this working.

gitbls commented 9 months ago

OK, I have my nvme up and running. Indeed, it doesn't look like a scsi disk, so the method that trim-enable implements won't work for nvme drives, at least for those connected using the geekworm x1001 that I'm using.

This is going to take some research. 😢

gitbls commented 9 months ago

Hold the phone. Or whatever. I just did sudo fstrim -v / and it trimmed the disk:

pt$ sudo fstrim -v /
/: 453.7 GiB (487199145984 bytes) trimmed

Not sure what this means just yet.

gitbls commented 9 months ago

As far as I can tell, trim is enabled on NVME disks by default (at least on my Kingston drive). I suppose there may be NVME drives that don't support trim, but there's no way using the technique implemented by sdm to enable them, either.

I've updated the trim-enable plugin (and satrim) to "do the right thing" by checking whether trim is enabled via lsblk --discard. If the drive doesn't have that provisioning_mode directory and trim is enabled already, it will report that. If trim isn't enabled, it will report that it can't be enabled.

This will be in sdm V11.3, coming soon (I hope 🤞)

gitbls commented 9 months ago

satrim in V11.3 should correct this. Please test. Thx!

dantchapman commented 9 months ago

Tested and no more errors. Thanks again for all your efforts!