Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkosi-initrd: honor x-initrd.attach options in crypttab #3136

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

aafeijoo-suse
Copy link
Contributor

@aafeijoo-suse aafeijoo-suse commented Oct 22, 2024

Entries in /etc/crypttab with the x-initrd.attach option are intended to be set up in the initrd.

Copy link
Contributor

@behrmann behrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code between fstab and crypttab is largely the same and should go into a shared function.

mkosi/initrd.py Outdated Show resolved Hide resolved
mkosi/initrd.py Outdated Show resolved Hide resolved
mkosi/initrd.py Outdated Show resolved Hide resolved
@DaanDeMeyer
Copy link
Contributor

So systemd already parses /sysroot/etc/fstab from inside the initrd, so I'm wondering if the /etc/fstab changes are really necessary?

@aafeijoo-suse
Copy link
Contributor Author

So systemd already parses /sysroot/etc/fstab from inside the initrd, so I'm wondering if the /etc/fstab changes are really necessary?

That is a good point. Simple test:

localhost:/home/dev # grep x-initrd.mount /etc/fstab
UUID=...  /var        btrfs  subvol=/@/var,x-initrd.mount        0  0
UUID=...  /root       btrfs  subvol=/@/root,x-initrd.mount       0  0
  • Without custom fstab in the initrd:
# journalctl -b-1 -o short-monotonic | grep -e root.mount -e var.mount -e Switching -e fstab
[    7.361337] localhost systemd[1]: Mounting sysroot.mount...
[    7.377509] localhost systemd[1]: Mounted sysroot.mount.
[    7.383766] localhost systemd-sysroot-fstab-check[504]: /sysroot/var should be mounted in the initrd, will request daemon-reload.
[    7.487911] localhost systemd-sysroot-fstab-check[504]: Requesting initrd-fs.target/start/replace...
[    7.500733] localhost systemd[1]: sysroot-root.mount: Directory /sysroot/root to mount over is not empty, mounting anyway.
[    7.500902] localhost systemd-sysroot-fstab-check[504]: Requesting swap.target/start/replace...
[    7.501448] localhost systemd[1]: Mounting sysroot-root.mount...
[    7.501782] localhost systemd[1]: sysroot-var.mount: Directory /sysroot/var to mount over is not empty, mounting anyway.
[    7.503385] localhost systemd[1]: Mounting sysroot-var.mount...
[    7.525342] localhost systemd[1]: Mounted sysroot-root.mount.
[    7.526440] localhost systemd[1]: Mounted sysroot-var.mount.
[    7.662725] localhost systemd[1]: Switching root.
  • With it:
# journalctl -b -o short-monotonic | grep -e root.mount -e var.mount -e Switching -e fstab
[    8.230834] localhost systemd[1]: root.mount: Directory /root to mount over is not empty, mounting anyway.
[    8.231434] localhost systemd[1]: Mounting root.mount...
[    8.231707] localhost systemd[1]: var.mount: Directory /var to mount over is not empty, mounting anyway.
[    8.233396] localhost systemd[1]: Mounting var.mount...
[    8.246182] localhost systemd[1]: Mounting sysroot.mount...
[    8.250963] localhost systemd[1]: Mounted root.mount.
[    8.251415] localhost systemd[1]: Mounted var.mount.
[    8.256304] localhost systemd[1]: Mounted sysroot.mount.
[    8.262160] localhost systemd-sysroot-fstab-check[509]: /sysroot/var should be mounted in the initrd, will request daemon-reload.
[    8.370742] localhost systemd-sysroot-fstab-check[509]: Requesting initrd-fs.target/start/replace...
[    8.384198] localhost systemd[1]: sysroot-root.mount: Directory /sysroot/root to mount over is not empty, mounting anyway.
[    8.384767] localhost systemd-sysroot-fstab-check[509]: Requesting swap.target/start/replace...
[    8.385252] localhost systemd[1]: Mounting sysroot-root.mount...
[    8.385632] localhost systemd[1]: sysroot-var.mount: Directory /sysroot/var to mount over is not empty, mounting anyway.
[    8.386926] localhost systemd[1]: Mounting sysroot-var.mount...
[    8.409683] localhost systemd[1]: Mounted sysroot-root.mount.
[    8.411513] localhost systemd[1]: Mounted sysroot-var.mount.
[    8.507986] localhost systemd[1]: Switching root.

@DaanDeMeyer
Copy link
Contributor

So without /etc/fstab in the initrd /root and /var are still mounted in /sysroot which is what you want? Or am I misunderstanding?

@aafeijoo-suse
Copy link
Contributor Author

So without /etc/fstab in the initrd /root and /var are still mounted in /sysroot which is what you want? Or am I misunderstanding?

No, you understood correctly, it's not necessary here. Thanks!

@aafeijoo-suse aafeijoo-suse changed the title mkosi-initrd: honor x-initrd options mkosi-initrd: honor x-initrd.attach options in crypttab Oct 22, 2024
Copy link
Contributor

@behrmann behrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM code-wise

mkosi/initrd.py Outdated Show resolved Hide resolved
@behrmann behrmann merged commit 9985e7e into systemd:main Oct 28, 2024
31 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants