About changing crypttab

I have installed TW on a fully encrypted partition during installation and the system is asking for the passphrase at the very beginning of the boot procedure. I discovered though that the options placed by the installer in crypttab do not allow trimming in the encrypted section.

Is it enough to add the ,discard option after the last existing option in crypttab and reboot the system to enable trimmimg or do I have to do anything else too?

Thank you.

How can we answer it without seeing the existing line to which you are going to add this option? Please use preformatted text (not bold, italic etc) when pasting /etc/crypttab content.

@alexsec

The discard option is disabled by default when using luks for security reasons. You can, of course, use a search engine to read about it if you want.

If you still want to enable it:

Edit /etc/crypttab

For example:

cr_root UUID=blah-blah-blah-blah none discard x-initrd.attach

discard must be before x-initrd.attach

Then run: sudo dracut -f and reboot

This line is incorrect. Read man crypttab.

It can be anywhere it you use the correct syntax.

It isn’t. No need to read man crypttab

No it can’t. Try it.

One thing is documentation, another is real world use.

I’ll try to reply to all your messages at once with this one.

@arvidjaar you’re right. When I tried to edit my post in order to add the crypttab line, the system wouldn’t allow me to edit it. I’m sorry I didn’t add it the first time I posted it.

I found the solution accidentally when I was searching for something else on the internet. Maybe you can verify that nothing else is to be done. I think it should be OK though since I’ve already tested trimming and it worked.

  1. I added the discard option in /etc/crypttab and now the file looks like this:

cr_root UUID=blah-blah-blah-blah none x-initrd.attach,discard

@snoopy the discard option works fine if it’s last as long as it is placed in the 4th (options) section separated from the other options by a comma. Not a space. It also worked in the previous distribution I was using before I switched to TW.

  1. I verified that the option issue_discards = 1 existed in /etc/lvm/lvm.conf, since I’m using lvm volumes inside the encrypted partition, and it was there.

  2. Finally I executed dracut -f --regenerate-all and rebooted the system.

  3. After the reboot I executed fstrim --fstab --verbose and it showed that both the /boot/efi and the encrypted root partitions had been trimmed.

I think everything should be OK now but, as I said above, I would appreciate it if you could verify that too.

Thank you.

@alexsec Sorry for the late reply.

Your solution looks correct to me. Trim will work. You are correct about ,discard

@arvidjaar Sorry for my arrogant reply. Your reply was correct.

2 Likes