View previous topic :: View next topic |
Author |
Message |
pingtoo Veteran
Joined: 10 Sep 2021 Posts: 1472 Location: Richmond Hill, Canada
|
Posted: Sun Mar 27, 2022 1:53 am Post subject: How to enable TRIM for logical volumes on USB device? |
|
|
Hi,
I have a SAMSUNG T5 1TB, it is connected over USB-3 port, I use lvm created several logical volumes (lv).
Initially I was not able to use fstrim for file system for any lv. then I learn I need to enable device's provisioning_mode by change its value to unmap. Also change /sys/block/sda/queue/discard_max_bytes to 2147450880.
After above I see lsblk -D changed to allow TRIM, Code: | NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda 0 512B 4G 0
├─vg0-swapvol 0 0B 0B 0
├─vg0-dockervol 0 0B 0B 0
├─vg0-uvol 0 0B 0B 0
├─vg0-s2 0 0B 0B 0
└─vg0-pi--3 0 0B 0B 0 |
However those lv remain no DISCARD setting (as in they are all zero).
So my question, is there a way to change them?
I tested by create new lv which did inherit the DISCARD setting from /dev/sda Code: | NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda 0 512B 4G 0
├─vg0-swapvol 0 0B 0B 0
├─vg0-dockervol 0 0B 0B 0
├─vg0-uvol 0 0B 0B 0
├─vg0-s2 0 0B 0B 0
├─vg0-pi--3 0 0B 0B 0
└─vg0-testlv 0 512B 4G 0 |
|
|
Back to top |
|
|
alamahant Advocate
Joined: 23 Mar 2019 Posts: 3948
|
Posted: Sun Mar 27, 2022 5:56 pm Post subject: |
|
|
For me this udev rule works
Code: |
ACTION=="add|change", ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="61f5", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
|
with T5.
You might get the ids by running
I am not sure it will work for lv also.
You might try it. _________________
Last edited by alamahant on Sun Mar 27, 2022 6:10 pm; edited 1 time in total |
|
Back to top |
|
|
NeddySeagoon Administrator
Joined: 05 Jul 2003 Posts: 54799 Location: 56N 3W
|
Posted: Sun Mar 27, 2022 5:59 pm Post subject: |
|
|
pingtoo,
Discard_over_USB
I found that logical volumes needed a reboot. See the note. _________________ Regards,
NeddySeagoon
Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail. |
|
Back to top |
|
|
pingtoo Veteran
Joined: 10 Sep 2021 Posts: 1472 Location: Richmond Hill, Canada
|
Posted: Sun Mar 27, 2022 7:48 pm Post subject: |
|
|
Hi,
Thanks for taking time review my question and give answers.
My problem is that logical volumes on the USB disk NOT having the TRIM enabled. I successful enable the USB disk by follow the Discard_over_USB.
So for example, under this condition, Code: | NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda 8:0 0 931.5G 0 disk 0 512B 4G 0
├─vg0-swapvol 254:0 0 4G 0 lvm [SWAP] 0 512B 4G 0
├─vg0-dockervol 254:1 0 50G 0 lvm /opt/docker 0 0B 0B 0
├─vg0-uvol 254:2 0 100G 0 lvm /u 0 0B 0B 0
├─vg0-s2 254:3 0 6G 0 lvm [SWAP] 0 512B 4G 0
├─vg0-pi--3 254:4 0 10G 0 lvm 0 0B 0B 0
└─vg0-testlv 254:5 0 100M 0 lvm /tmp/mnt 0 512B 4G 0 |
fstrim failed for vg0/dockervol Code: | root@fatman:~# fstrim -v /opt/docker/
fstrim: /opt/docker/: the discard operation is not supported |
However it work for vg0/testlv Code: | root@fatman:~# fstrim -v /tmp/mnt
/tmp/mnt: 91.3 MiB (95748096 bytes) trimmed |
vg0/testlv was created after the USB disk enable TRIM setting.
vg0/swapvol and vg0/s2 got enabled after I did a lvreduce. However all LVs will get reset back to 0 after reboot. Only the USB disk remain enabled. |
|
Back to top |
|
|
|