You are not logged in.

#1 2019-05-04 09:40:35

JayDoe
Member
Registered: 2014-09-20
Posts: 27

Trim with full-disc-encrypted YKFDE/LUKS/LVM not working [SOLVED]

Hi,
I want to setup trim passthrough on my setup using a SSD, Luks and LVM.

At the moment, my trim looks like this:

#lsblk --discard

NAME                 DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda                         0      512B       2G         0
├─sda1                      0      512B       2G         0
└─sda2                      0      512B       2G         0
  └─root                    0        0B       0B         0
    ├─Archlinux-swap        0        0B       0B         0
    ├─Archlinux-root        0        0B       0B         0
    └─Archlinux-home        0        0B       0B         0

# dmsetup table | grep crypt
root: 0 241628363 crypt aes-xts-plain64 :64:logon:cryptsetup:... 0 8:2 32768

# hdparm -I /dev/sda | grep TRIM
	   *	Data Set Management TRIM supported (limit 8 blocks)
	   *	Deterministic read data after TRIM

so it looks like already on my LUKS TRIM is not active? Hdparm shows, that my SSD supports TRIM.

My /etc/fstab looks like this:

#cat /etc/fstab
# /dev/mapper/Archlinux-root
UUID=...	/         	ext4      	rw,relatime,discard	0 1

# /dev/sda1
UUID=...      	/boot     	vfat      	rw,relatime,discard,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro	0 2

# /dev/mapper/Archlinux-swap
UUID=...	none      	swap      	defaults 	0 0

# /dev/mapper/Archlinux-home
UUID=...	/home		ext4		rw,relatime,discard	0 1

and my /etc/crypttab is empty, since it's a full disc encryption. In my LVM configuration /etc/lvm/lvm.conf I enabled discards:

cat /etc/lvm/lvm.conf |grep issue_discard
	# Configuration option devices/issue_discards.
	issue_discards = 1

My grub cmd line looks like this:

#cat /etc/default/grub |grep GRUB_CMDLINE
GRUB_CMDLINE_LINUX_DEFAULT="quiet cryptdevice=/dev/sda2:root:allow-discards root=/dev/mapper/Archlinux-root luks.options=discard"
GRUB_CMDLINE_LINUX=""

So what am I missing? Why isn't trim enabled on my logical volumes?

Thanks for your help!

Last edited by JayDoe (2019-05-04 11:50:15)

Offline

#2 2019-05-04 10:55:35

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 596

Re: Trim with full-disc-encrypted YKFDE/LUKS/LVM not working [SOLVED]

Here's the problem:

JayDoe wrote:

# dmsetup table | grep crypt
root: 0 241628363 crypt aes-xts-plain64 :64:logon:cryptsetup:... 0 8:2 32768

There should be "allow_discards" at the end of the line, https://wiki.archlinux.org/index.php/Dm … ives_(SSD) .

For some reason cryptdevice=/dev/sda2:root:allow-discards doesn't get applied. Did you regenerate /boot/grub.cfg after changing /etc/default/grub?
You can also try removing the "luks.options=discard" option as it looks like it could cause problems.

Offline

#3 2019-05-04 11:07:45

JayDoe
Member
Registered: 2014-09-20
Posts: 27

Re: Trim with full-disc-encrypted YKFDE/LUKS/LVM not working [SOLVED]

Thanks for your reply. Yes, I always run both,

# grub-mkconfig -o /boot/grub/grub.cfg 
# mkinitcpio -P

Also I tried already removing luks.options=discard, it still doesn't work.

Offline

#4 2019-05-04 11:24:22

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 596

Re: Trim with full-disc-encrypted YKFDE/LUKS/LVM not working [SOLVED]

Try unlocking the device manually from a live system with e.g.

cryptsetup --allow-discards open /dev/sda2 root

and check

dmsetup table

Also post your /boot/grub.cfg.

Offline

#5 2019-05-04 11:33:38

JayDoe
Member
Registered: 2014-09-20
Posts: 27

Re: Trim with full-disc-encrypted YKFDE/LUKS/LVM not working [SOLVED]

I just solved it. The problem was my Yubikey setup... following the hint in https://github.com/agherzan/yubikey-ful … /issues/35 and https://wiki.archlinux.org/index.php/Dm … ives_(SSD), I added

# cat /etc/ykfde.conf |grep LUKS_OPTIONS
YKFDE_LUKS_OPTIONS="--allow-discards"

and ran

# cryptsetup --allow-discards --persistent refresh /dev/sda2 root

and rebooted.

# dmsetup table | grep crypt
root: 0 241628363 crypt aes-xts-plain64 :64:logon:cryptsetup:... 0 8:2 32768 1 allow_discards
[root@zenbook julian]# lsblk --discard
NAME                 DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda                         0      512B       2G         0
├─sda1                      0      512B       2G         0
└─sda2                      0      512B       2G         0
  └─root                    0      512B       2G         0
    ├─Archlinux-swap        0      512B       2G         0
    ├─Archlinux-root        0      512B       2G         0
    └─Archlinux-home        0      512B       2G         0

Even though it is more a workaround, it's working fine now. Thank you

Offline

Board footer

Powered by FluxBB