You are not logged in.

#1 2015-07-13 19:57:05

netpumber
Member
Registered: 2009-09-20
Posts: 134

[SOLVED] TRIM configuration in a system with LVM and LUKS.

Hello. I just bought a new PC and installed Arch linux.

It has one HDD 500GB(sdb) and 120GB SSD (sda). Both of them are encrypted using LUKS system on LVM.

On the SSD there is :
a boot partition (sda1)
and a lvm pool (sda2) which contains swap and /

The HDD contains another lvm pool which contains only the home.

So now i want to setup the TRIM for the SSD and i have some Qs.

1) I enable fstrim timer by running

systemctl enable fstrim.timer

At wiki page says that

Enabling the timer will activate the service weekly, which will then trim all mounted filesystems on devices that support the discard operation

Fstrim understands on its own which devices supports the discard operation or i have to label it on fstab file ?

2) TRIM for LVM level
I just change the value of issue_discards option from 0 to 1 in /etc/lvm/lvm.conf as wiki says.

Does the other HDD (sdb) will be affected from this configuration ? Am i gonna loose data from that disk ?
I'm asking because there is no specification on which lvm-pool discard issue should take effect on.

3)Crypttab level
What's going here ? I'm little bit confused.

a)

For non-root filesystems, configure /etc/crypttab to include discard in the list of options for encrypted block devices located on a SSD

At my /etc/crypttab file, i have only one line activated and that's the line which says at crypttab to decrypt the HDD (sdb) using a specific key file. Nothing else.
What's gonna happen with the lvm pool (sda2) which contains swap and / ?

b) For root filesystem i have to change the cryptdevice option.
I have to say that i'm using systemd-boot/gummiboot and the /boot/loader/entries/arch.conf file looks like that

title Arch Linux Encrypted
linux /vmlinuz-linux
initrd /initramfs-linux.img
options cryptdevice=UUID=<UUID>:<mapped-name> root=UUID=<luks-UUID> quiet rw

Where i suppose to add the

:allow-discards

here

options cryptdevice=UUID=<UUID>:<mapped-name>:allow-discards root=UUID=<luks-UUID> quiet rw

or here

options cryptdevice=UUID=<UUID>:<mapped-name> root=UUID=<luks-UUID>:allow-discards quiet rw

Finally, is there any way to understand that all went good and the TRIM is actually working ?

Thank you.

Last edited by netpumber (2015-07-14 11:39:53)

Offline

#2 2015-07-13 20:05:05

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,732
Website

Re: [SOLVED] TRIM configuration in a system with LVM and LUKS.

netpumber wrote:

Fstrim understands on its own which devices supports the discard operation

Yes.

netpumber wrote:

is there any way to understand that all went good and the TRIM is actually working ?

If set to "weekly", it runs at 12:00 on Sunday or the first boot after that time -- you can tell when it's running 'cos the drive light stays on even if the drive isn't being accessed by you and the SSD runs like a slow spinning rust drive.

Offline

#3 2015-07-13 20:21:18

frostschutz
Member
Registered: 2013-11-15
Posts: 1,420

Re: [SOLVED] TRIM configuration in a system with LVM and LUKS.

netpumber wrote:

2) TRIM for LVM level
I just change the value of issue_discards option from 0 to 1 in /etc/lvm/lvm.conf as wiki says.

Trim always works with LVM, there is no setting that would disable trim. (Unlike LUKS which needs --allow-discards).

issue_discards is about trimming on lvremove. You can do that manually with blkdiscard instead.

netpumber wrote:

Finally, is there any way to understand that all went good and the TRIM is actually working ?

http://unix.stackexchange.com/a/85880/30851

Offline

#4 2015-07-14 08:35:10

netpumber
Member
Registered: 2009-09-20
Posts: 134

Re: [SOLVED] TRIM configuration in a system with LVM and LUKS.

Thank you very much. What about the third one ? Any idea about that?

Offline

#5 2015-07-14 09:17:39

frostschutz
Member
Registered: 2013-11-15
Posts: 1,420

Re: [SOLVED] TRIM configuration in a system with LVM and LUKS.

' dmsetup table ' will show you all device mappings. ' dmsetup table | grep crypt ' will show all device mappings which are involved in encryption, i.e. your LUKS containers.

a LUKS container with allow discards enabled should show as thus:

luksSSD1: 0 125034496 crypt aes-xts-plain64 0 0 9:0 4096 1 allow_discards

note the allow_discards at the end of the line. in comparison a container opened w/o allow_discards:

luksHDD1: 0 2930235392 crypt aes-xts-plain64 0 0 9:1 4096

if your LUKS containers as are backed by SSD storage have this allow_discards in the dmsetup table, everything is fine ...

Offline

#6 2015-07-14 10:55:56

netpumber
Member
Registered: 2009-09-20
Posts: 134

Re: [SOLVED] TRIM configuration in a system with LVM and LUKS.

There is no allow_dicards flag in SSD

This is how it looks like the output

lvmRootPool: 0 233385984 crypt aes-xts-plain64 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0 8:17 4096

As i said in my first post i didn't add the allow-discards flag on cryptdevice option at bootloader because i coudn't understood where to add it.

Where i suppose to add the
:allow-discards
here
options cryptdevice=UUID=<UUID>:<mapped-name>:allow-discards root=UUID=<luks-UUID> quiet rw
or here
options cryptdevice=UUID=<UUID>:<mapped-name> root=UUID=<luks-UUID>:allow-discards quiet rw

Edit:

Ok did the first one and now allow-discards appears on dmsetup table command.

Last edited by netpumber (2015-07-14 11:17:44)

Offline

Board footer

Powered by FluxBB