Announcement

Collapse
No announcement yet.

Trim (fstrim) does not work on volumes of an encrypted LVM-group after boot

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Trim (fstrim) does not work on volumes of an encrypted LVM-group after boot

    Need help. The OS is installed on a partition of an encrypted LVM group (LVM + LUKS). After booting, Trim (fstrim) does not work on any of the LVM group volumes:

    Code:
    fstrim: /media/user1/v1/: the discard operation is not supported
    
    …
    
    fstrim: /: the discard operation is not supported
    What should I do to make Trim work?

    However, if the same volumes are opened using "sudo cryptsetup open …", Trim works correctly!

    DETAILED SEQUENCE OF MY ACTIONS:

    1. Took a new SSD
    2. Created and prepared LVM + LUKS partitions on it:

    Code:
    sdb 8:16 0 119,2G 0 disk
    ├─sdb1 8:17 0 1G 0 part
    ├─sdb2 8:18 0 48,8G 0 part
    │ └─luks-a254975b-86c5-4e8d-9e29-f4519e1f90d8 252:0 0 48,8G 0 crypt
    │ ├─My_group-Root 252:1 0 19,5G 0 lvm
    │ ├─My_group-v1 252:2 0 1000M 0 lvm
    3. Installed OS Kubuntu 24.04.2, choosing:

    sdb1 as /boot
    My_group-Root as /


    4. Everything installed fine, the OS boots and works fine. Trim for the partitions of the LVM group does not work.

    5. I Specified the parameters in "/etc/default/grub" for Trim to work:

    Code:
    /etc/default/grub
    
    GRUB_CMDLINE_LINUX="cryptdevice=UUID=A5265A32-048A-4DC4-8FFE-72DE69731B61:luks-a254975b-86c5-4e8d-9e29-f4519e1f90d8:allow-discards"

    In "/etc/lvm/lvm.conf":

    Code:
    devices {
     issue_discards = 1
    }


    6. sudo update-grub, then reboot


    7. Trim DOES NOT work

    QUESTION: What should I do to make Trim work?

    ADDITIONAL INFORMATION:

    2.1 I boot the computer from another OS (Kubuntu 24.10)

    2.2a If the same LVM group volumes are opened with "sudo cryptsetup open …", then Trim works properly:

    Code:
    user1@computer1:~$ sudo cryptsetup open --allow-discards --persistent --type luks /dev/sdb2 luks-a254975b-86c5-4e8d-9e29-f4519e1f90d8
    user1@computer1:~$ sudo fstrim -v /media/user1/v1/
    /media/user1/v1/: 965,8 MiB (1012744192 bytes) trimmed
    2.2b But if the same LVM volumes are opened using KDE GUI tools (KDE Partition Manager), then Trim does NOT work:

    Code:
    fstrim: /media/user1/v1/: the discard operation is not supported
Working...
X