Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to include non-empty /etc/crypttab into initramfs?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
nagmat84
Apprentice
Apprentice


Joined: 27 Mar 2007
Posts: 290

PostPosted: Sun Nov 10, 2024 10:33 am    Post subject: How to include non-empty /etc/crypttab into initramfs? Reply with quote

I have LUKS with an encrypted rootfs and want Dracut to include my /etc/crypttab into the initramfs. How do I do that?

No matter what I do, I always end up with an empty /etc/crypttab in the initramfs. After googling I tried different things, but non of them worked
  1. I created /etc/cryttab.initramfs with the same content, because somewhere was written that Dracut uses that file to be copied as /etc/crypttab
  2. I added an explicit "install" directive to the Dracut config to copy /etc/crypttab to the initramgs indepedent of what any Dracut module does
  3. Somewhere I read that Dractut does not simply copy the file, but tries to parse it itself and is very picky about unbalanced quotes in /etc/crypttab which may result in an empty file, if Dracut isn't able to parser it
From my own quick inspection of the Dracut module 90crypt, point 3 seems plausible. There are various spots where the scripts of that Dracut module read /etc/crypttab. This might also explain why point 2 does not work: even if the cypttab was included unchanged, it might eventually become overwritten by some other Dracut mechanism.

/etc/crypttab{.initramfs}
Code:
# Volume Name    Encrypted Device                              Key File    Options
root             UUID=a1e92a68-a977-4c99-8e94-5ae023b52ff1     -           discard,fido2-device=auto,token-timeout=0


/etc/dracut.conf.d/modules-luks.conf
Code:
add_dracutmodules+=" crypt fido2 systemd-cryptsetup "
# The Breeze theme for Plymouth only shows an input box for the
# LUKS-encrypted root partition, if the libraries
#
#  - breeze-text.so
#  - label.so
#  - text.so
#
# are included.
# The Dracut module for Plymouth does not automatically pull in
# the necessary dependencies.
#
# See:
#
# - https://github.com/adi1090x/plymouth-themes/issues/10#issuecomment-643362208
# - https://github.com/adi1090x/plymouth-themes/issues/10#issuecomment-643600359
#
install_items+=" /etc/fonts/fonts.conf /usr/lib64/plymouth/breeze-text.so /usr/lib64/plymouth/label.so /usr/lib64/plymouth/text.so /usr/share/fonts/noto/NotoSans-Regular.ttf /usr/share/fonts/noto/NotoSerif-Regular.ttf "
install_optional_items+=" /etc/crypttab "
Back to top
View user's profile Send private message
sMueggli
Guru
Guru


Joined: 03 Sep 2022
Posts: 513

PostPosted: Sun Nov 10, 2024 1:06 pm    Post subject: Re: How to include non-empty /etc/crypttab into initramfs? Reply with quote

nagmat84 wrote:
I have LUKS with an encrypted rootfs and want Dracut to include my /etc/crypttab into the initramfs.


Why?
Back to top
View user's profile Send private message
nagmat84
Apprentice
Apprentice


Joined: 27 Mar 2007
Posts: 290

PostPosted: Sun Nov 10, 2024 1:36 pm    Post subject: Reply with quote

Why what? Why I want to include /etc/crypttab? Because I only want to have a single place where I configure all LUKS settings, like timeouts etc.
Back to top
View user's profile Send private message
zen_desu
n00b
n00b


Joined: 25 Oct 2024
Posts: 56

PostPosted: Sun Nov 10, 2024 3:33 pm    Post subject: Reply with quote

Are you running dracut in hostonly mode?

The only LUKS info which makes sense to have in the initramfs is the root info, the rest isn't really relevant. The initramfs can mount the root, switch to it, and then systemd can use the crypttab to mount the rest.
_________________
µgRD dev
Wiki writer
Back to top
View user's profile Send private message
sMueggli
Guru
Guru


Joined: 03 Sep 2022
Posts: 513

PostPosted: Mon Nov 11, 2024 5:49 pm    Post subject: Reply with quote

nagmat84 wrote:
Why what? Why I want to include /etc/crypttab? Because I only want to have a single place where I configure all LUKS settings, like timeouts etc.


And which tool will read the crypttab from the initramfs (and not the original /etc/crypttab)?
Back to top
View user's profile Send private message
zen_desu
n00b
n00b


Joined: 25 Oct 2024
Posts: 56

PostPosted: Mon Nov 11, 2024 5:54 pm    Post subject: Reply with quote

sMueggli wrote:
nagmat84 wrote:
Why what? Why I want to include /etc/crypttab? Because I only want to have a single place where I configure all LUKS settings, like timeouts etc.


And which tool will read the crypttab from the initramfs (and not the original /etc/crypttab)?


I think modern versions of dracut will pull systemd into the initramfs, so if you have a crypttab in there, a systemd service can read and use it.
_________________
µgRD dev
Wiki writer
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum