You are not logged in.

#1 2013-08-07 00:09:12

daemoon
Member
Registered: 2013-02-21
Posts: 7

[SOLVED] fstrim fails on LUKS-device

Hello,

today I've encountered a strange issue when installing Arch to my new SSD. I've read a lot about the options you have to set to enable TRIM and tried to configure my system according to these tutorials.

First of all the error:

# fstrim -v /home
fstrim: /home: FITRIM ioctl failed: Operation not supported.

These are my devices:

# blkid
/dev/sda1: UUID="d6e350c2-3b85-4cc8-8802-326f310912d9" TYPE="ext4" 
/dev/sda2: UUID="8c3ea242-7b75-41d2-93f9-75b3c65aaa74" TYPE="crypto_LUKS" 
/dev/mapper/home: UUID="a6419946-da6f-4ea7-9108-e882fb322fd4" TYPE="ext4"

"/dev/sda1" is the unencrypted root filesystem, "/dev/sda2" is the encrypted LUKS-device for /dev/mapper/home, which is mounted in /home.

I've added the mapped device to my /etc/fstab with the "discard" option:

/dev/sda1           	/         	ext4      	rw,discard,noatime	 0 1
UUID=a6419946-da6f-4ea7-9108-e882fb322fd4	/home	ext4	rw,discard,noatime	0	1

Then I configured this boot option line for GRUB to enable the discard option and updated the grub.cfg, of course:

linux 	/boot/vmlinuz-linux root=UUID=d6e350c2-3b85-4cc8-8802-326f310912d9 ro  cryptdevice=/dev/sda2:home:allow-discards root_trim=yes quiet

Finally I enabled discard in /etc/crypttab:

home    UUID=8c3ea242-7b75-41d2-93f9-75b3c65aaa74       none    luks,discard

To realize these changes at the next reboot I also made a new initcpio with

# mkinitpcio -p linux


Having then rebooted I tried whether I was successful with

# dmsetup table /dev/mapper/home --showkeys

.

Some tutorials told me that there had to be "allow_discards" but there wasn't. I assume that I have forgotten something and TRIM doesn't work as a result.
Thank you in advance.

Last edited by daemoon (2013-08-11 12:02:01)

Offline

#2 2013-08-07 00:50:46

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,130

Re: [SOLVED] fstrim fails on LUKS-device

Not sure but you are trying to apply allow-discards to the physical partition (/dev/sda2) rather than the mapped device, right? Whereas the wiki does it the other way - at least the example at https://wiki.archlinux.org/index.php/LU … _.28SSD.29 suggests that.

Note that I have no idea if this matters.

I can tell you that the final figure on your fstab line for /home should be 2 rather than 1 but that is not the cause of your problem. Also, if you have the fsck hook in initramfs, you should change ro to rw on grub's kernel command line. If you don't have the hook, you should leave it as is.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2013-08-07 01:08:03

daemoon
Member
Registered: 2013-02-21
Posts: 7

Re: [SOLVED] fstrim fails on LUKS-device

Unfortunately this was no use, fstrim still returns the same error. But thank you very much for your advices!

Offline

#4 2013-08-08 15:52:10

h00ver
Member
Registered: 2013-08-08
Posts: 4

Re: [SOLVED] fstrim fails on LUKS-device

Trim requires root-rights, try:

sudo fstrim -v /home

Offline

#5 2013-08-08 16:26:50

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [SOLVED] fstrim fails on LUKS-device

the crypttab option is "allow-discards", not "discard" (see man page wink ).

Last edited by 65kid (2013-08-08 16:27:06)

Offline

#6 2013-08-08 23:10:33

daemoon
Member
Registered: 2013-02-21
Posts: 7

Re: [SOLVED] fstrim fails on LUKS-device

Thank you very much, 65kid! Somehow I got confused about this. I'm glad it works now. smile

Offline

Board footer

Powered by FluxBB