Enable DISCARD/TRIM support for LUKS encrypted disk

The Gist

# lsblk -o +UUID
NAME                                          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS UUID
sda                                             8:0    0 931.5G  0 disk              
└─sda1                                          8:1    0 931.5G  0 part              8a5e226f-a1ca-4df1-b7bc-174c20c8e8c5
  └─luks-8a5e226f-a1ca-4df1-b7bc-174c20c8e8c5 253:1    0 931.5G  0 crypt             FXN8Y5-9FzZ-1QX4-HGtt-knmO-hvO1-kmKtmG
    └─vg_SSD_1000G-data                       253:2    0 931.5G  0 lvm   /mnt/data   547d0623-0a8e-4f9b-aab7-08fa9484cf4e
sdb                                             8:16   1     0B  0 disk              
nvme0n1                                       259:0    0 931.5G  0 disk              
├─nvme0n1p1                                   259:1    0   600M  0 part  /boot/efi   014A-87D7
├─nvme0n1p2                                   259:2    0     1G  0 part  /boot       38b0586f-2715-4493-a548-e12902f1b68d
└─nvme0n1p3                                   259:3    0 929.9G  0 part              4eb7d347-974d-4dec-8396-d4b5891d0f52
  └─luks-4eb7d347-974d-4dec-8396-d4b5891d0f52 253:0    0 929.9G  0 crypt /home       6aba9a5f-eb7b-43f2-b913-b04620b57e88
                                                                         /           

# cryptsetup --perf-no_read_workqueue --perf-no_write_workqueue --allow-discards --persistent refresh luks-4eb7d347-974d-4dec-8396-d4b5891d0f52

# cryptsetup luksDump  /dev/sda1 | grep Flags
Flags:          allow-discards no-read-workqueue no-write-workqueue

Sources

  • https://wiki.archlinux.org/title/Dm-crypt/Specialties#Discard/TRIM_support_for_solid_state_drives_(SSD)
  • https://wiki.archlinux.org/title/Dm-crypt/Specialties#Disable_workqueue_for_increased_solid_state_drive_(SSD)_performance
  • https://gist.github.com/Edu4rdSHL/8f97eb1bab454fb2b348f1167cee7cd2

 

Leave a Reply

Your email address will not be published.