You are not logged in.

#26 2025-10-24 13:58:30

unixman
Member
Registered: 2015-03-12
Posts: 181

Re: SOLVED: Cannot get TRIM working on external NVME-SSDs-

IIRC that attrubute names MATCH  exacly with UDEV. You should be use them as is.

Q: I guess I should be using 'vendor' or 'subsystem_vendor' instead of 'idVendor'

Yes.

Last edited by unixman (2025-10-24 14:00:11)

Offline

#27 2025-10-24 15:46:21

Elmario
Member
Registered: 2023-08-21
Posts: 91

Re: SOLVED: Cannot get TRIM working on external NVME-SSDs-

Right!
I got it working with the udev rules looking like this

cat /etc/udev/rules.d/10-uas-discard.rules 
#Enable TRIM for external SSDs
#Realtek RTL9210 enclosures
ACTION=="add|change", ATTRS{product}=="Sabrent", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"

#JMicron
ACTION=="add|change", ATTRS{vendor}=="JMicron", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"

#ShargeDisk
ACTION=="add|change", ATTRS{product}=="SHARGE DISK", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"

I hope just using the vendor's name (as I did not find any other value that would have been the actual device because all the vendor IDs and devic IDs seem to be the USB controllers themselves) won't cause any problems. But having them also filtered with scsi_disk should probably sufficient for not affecting any devices that might not like it.

And in case I got another new or temporary enclosure with different controller I can use the script for a fast fix.

Thank you very much, people! smile

Last edited by Elmario (2025-10-24 16:13:51)

Offline

#28 2025-10-24 18:40:05

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 69,728

Re: SOLVED: Cannot get TRIM working on external NVME-SSDs-

Is there nothing like a "product" file next to the vendor one?

Offline

#29 2025-10-24 23:01:14

Elmario
Member
Registered: 2023-08-21
Posts: 91

Re: SOLVED: Cannot get TRIM working on external NVME-SSDs-

Seemingly not.

ls -l /sys/devices/pci0000:00/0000:00:08.3/0000:08:00.4/usb10/10-1/10-1.1/10-1.1:1.0/host1/target1:0:0/1:0:0:0/scsi_disk/1:0:0:0/device/
insgesamt 0
-r--r--r-- 1 root root 4096 25. Okt 00:56 access_state
-r--r--r-- 1 root root 4096 25. Okt 00:56 blacklist
drwxr-xr-x 3 root root    0 25. Okt 00:56 block
drwxr-xr-x 3 root root    0 25. Okt 00:56 bsg
-rw-r--r-- 1 root root 4096 25. Okt 00:56 cdl_enable
-r--r--r-- 1 root root 4096 25. Okt 00:56 cdl_supported
--w------- 1 root root 4096 25. Okt 00:56 delete
-r--r--r-- 1 root root 4096 25. Okt 00:56 device_blocked
-r--r--r-- 1 root root 4096 25. Okt 00:56 device_busy
-rw-r--r-- 1 root root 4096 25. Okt 00:56 dh_state
lrwxrwxrwx 1 root root    0 25. Okt 00:56 driver -> ../../../../../../../../../../../bus/scsi/drivers/sd
-rw-r--r-- 1 root root 4096 25. Okt 00:56 eh_timeout
-r--r--r-- 1 root root 4096 25. Okt 00:56 evt_capacity_change_reported
-r--r--r-- 1 root root 4096 25. Okt 00:56 evt_inquiry_change_reported
-r--r--r-- 1 root root 4096 25. Okt 00:56 evt_lun_change_reported
-r--r--r-- 1 root root 4096 25. Okt 00:56 evt_media_change
-r--r--r-- 1 root root 4096 25. Okt 00:56 evt_mode_parameter_change_reported
-r--r--r-- 1 root root 4096 25. Okt 00:56 evt_soft_threshold_reached
lrwxrwxrwx 1 root root    0 25. Okt 00:56 generic -> scsi_generic/sg2
-r--r--r-- 1 root root    0 25. Okt 00:56 inquiry
-r--r--r-- 1 root root 4096 25. Okt 00:56 iocounterbits
-r--r--r-- 1 root root 4096 25. Okt 00:56 iodone_cnt
-r--r--r-- 1 root root 4096 25. Okt 00:56 ioerr_cnt
-r--r--r-- 1 root root 4096 25. Okt 00:56 iorequest_cnt
-r--r--r-- 1 root root 4096 25. Okt 00:56 iotmo_cnt
-r--r--r-- 1 root root 4096 25. Okt 00:56 modalias
-r--r--r-- 1 root root 4096 25. Okt 00:56 model
drwxr-xr-x 2 root root    0 25. Okt 00:56 power
-r--r--r-- 1 root root 4096 25. Okt 00:56 preferred_path
-r--r--r-- 1 root root 4096 25. Okt 00:56 queue_depth
-rw-r--r-- 1 root root 4096 25. Okt 00:56 queue_type
--w------- 1 root root 4096 25. Okt 00:56 rescan
-r--r--r-- 1 root root 4096 25. Okt 00:56 rev
drwxr-xr-x 3 root root    0 25. Okt 00:56 scsi_device
drwxr-xr-x 3 root root    0 25. Okt 00:56 scsi_disk
drwxr-xr-x 3 root root    0 25. Okt 00:56 scsi_generic
-r--r--r-- 1 root root 4096 25. Okt 00:56 scsi_level
-rw-r--r-- 1 root root 4096 25. Okt 00:56 state
lrwxrwxrwx 1 root root    0 25. Okt 00:56 subsystem -> ../../../../../../../../../../../bus/scsi
-rw-r--r-- 1 root root 4096 25. Okt 00:56 timeout
-r--r--r-- 1 root root 4096 25. Okt 00:56 type
-rw-r--r-- 1 root root 4096 25. Okt 00:56 uevent
-r--r--r-- 1 root root 4096 25. Okt 00:56 vendor
-r--r--r-- 1 root root    0 25. Okt 00:56 vpd_pg0
-r--r--r-- 1 root root    0 25. Okt 00:56 vpd_pg80
-r--r--r-- 1 root root    0 25. Okt 00:56 vpd_pg83
-r--r--r-- 1 root root    0 25. Okt 00:56 vpd_pgb0
-r--r--r-- 1 root root    0 25. Okt 00:56 vpd_pgb1
-r--r--r-- 1 root root    0 25. Okt 00:56 vpd_pgb2
-r--r--r-- 1 root root 4096 25. Okt 00:56 wwid

This is for the JMicron controller. I actually have two identical enclosures of this model, with both the same model of SS inside, but different firmware that I flashed on one trying to improve it's overall behaviour (because of the SMART issues I mentioned before n this thread).
Both firmwares offer a 'vendor' attribute which is just 'JMicron' and a 'model' attribute, which contains just 'Generic' for the one I flashed and 'Tech' for the one I did not flash. Maybe I could change the model string by checking the flash utility for if it's configurable, but that would feel a bit too hack for my taste, as of course I'd like to have other controllers of the type working, too without having to customize their firmware first.
I don't know why all these device pathes are full of links to other devices or the same device again, but I think there's no use in searching through all the symlinks for adequate attributes, is it?

For the way more far spread thus important Realtek enclosures I found a better attribute in between, which is:
ATTRS{model}==""RTL9210B-CG"

For the Sharge Disk then again, it's looking like this:

ls -l /sys/devices/pci0000:00/0000:00:08.3/0000:08:00.4/usb10/10-1/10-1.1/10-1.1:1.0/host1/target1:0:0/1:0:0:0/scsi_disk/1:0:0:0/device/
insgesamt 0
-r--r--r-- 1 root root 4096 25. Okt 01:08 access_state
-r--r--r-- 1 root root 4096 25. Okt 01:08 blacklist
drwxr-xr-x 3 root root    0 25. Okt 01:07 block
drwxr-xr-x 3 root root    0 25. Okt 01:07 bsg
-rw-r--r-- 1 root root 4096 25. Okt 01:08 cdl_enable
-r--r--r-- 1 root root 4096 25. Okt 01:08 cdl_supported
--w------- 1 root root 4096 25. Okt 01:08 delete
-r--r--r-- 1 root root 4096 25. Okt 01:08 device_blocked
-r--r--r-- 1 root root 4096 25. Okt 01:08 device_busy
-rw-r--r-- 1 root root 4096 25. Okt 01:08 dh_state
lrwxrwxrwx 1 root root    0 25. Okt 01:08 driver -> ../../../../../../../../../../../bus/scsi/drivers/sd
-rw-r--r-- 1 root root 4096 25. Okt 01:08 eh_timeout
-r--r--r-- 1 root root 4096 25. Okt 01:08 evt_capacity_change_reported
-r--r--r-- 1 root root 4096 25. Okt 01:08 evt_inquiry_change_reported
-r--r--r-- 1 root root 4096 25. Okt 01:08 evt_lun_change_reported
-r--r--r-- 1 root root 4096 25. Okt 01:08 evt_media_change
-r--r--r-- 1 root root 4096 25. Okt 01:08 evt_mode_parameter_change_reported
-r--r--r-- 1 root root 4096 25. Okt 01:08 evt_soft_threshold_reached
lrwxrwxrwx 1 root root    0 25. Okt 01:08 generic -> scsi_generic/sg2
-r--r--r-- 1 root root    0 25. Okt 01:08 inquiry
-r--r--r-- 1 root root 4096 25. Okt 01:08 iocounterbits
-r--r--r-- 1 root root 4096 25. Okt 01:08 iodone_cnt
-r--r--r-- 1 root root 4096 25. Okt 01:08 ioerr_cnt
-r--r--r-- 1 root root 4096 25. Okt 01:08 iorequest_cnt
-r--r--r-- 1 root root 4096 25. Okt 01:08 iotmo_cnt
-r--r--r-- 1 root root 4096 25. Okt 01:08 modalias
-r--r--r-- 1 root root 4096 25. Okt 01:07 model
drwxr-xr-x 2 root root    0 25. Okt 01:08 power
-r--r--r-- 1 root root 4096 25. Okt 01:08 preferred_path
-r--r--r-- 1 root root 4096 25. Okt 01:08 queue_depth
-rw-r--r-- 1 root root 4096 25. Okt 01:08 queue_type
--w------- 1 root root 4096 25. Okt 01:08 rescan
-r--r--r-- 1 root root 4096 25. Okt 01:07 rev
drwxr-xr-x 3 root root    0 25. Okt 01:07 scsi_device
drwxr-xr-x 3 root root    0 25. Okt 01:07 scsi_disk
drwxr-xr-x 3 root root    0 25. Okt 01:07 scsi_generic
-r--r--r-- 1 root root 4096 25. Okt 01:08 scsi_level
-rw-r--r-- 1 root root 4096 25. Okt 01:08 state
lrwxrwxrwx 1 root root    0 25. Okt 01:07 subsystem -> ../../../../../../../../../../../bus/scsi
-rw-r--r-- 1 root root 4096 25. Okt 01:08 timeout
-r--r--r-- 1 root root 4096 25. Okt 01:07 type
-rw-r--r-- 1 root root 4096 25. Okt 01:07 uevent
-r--r--r-- 1 root root 4096 25. Okt 01:07 vendor
-r--r--r-- 1 root root    0 25. Okt 01:08 vpd_pg0
-r--r--r-- 1 root root    0 25. Okt 01:08 vpd_pg80
-r--r--r-- 1 root root    0 25. Okt 01:08 vpd_pg83
-r--r--r-- 1 root root    0 25. Okt 01:08 vpd_pgb0
-r--r--r-- 1 root root    0 25. Okt 01:08 vpd_pgb1
-r--r--r-- 1 root root    0 25. Okt 01:08 vpd_pgb2
-r--r--r-- 1 root root 4096 25. Okt 01:08 wwid

There's only vendor ('SHARGE') and model ('DISK'). But 'Sharge DISK' is actually what they are calling their product, while the two other NVME related products they have are named 'SHARGE DISK Pro' and 'SHARGE DISK Plus', so I guess the filtering is sufficient for this enclosure.

Last edited by Elmario (2025-10-24 23:50:59)

Offline

Board footer

Powered by FluxBB