random-archer / mkinitcpio-systemd-tool

Provisioning tool for systemd in initramfs (systemd-tool)
https://www.archlinux.org/packages/community/any/mkinitcpio-systemd-tool/
Other
112 stars 27 forks source link

Sysroot on Btrfs on LVM on LUKS #68

Closed kittydoor closed 4 years ago

kittydoor commented 4 years ago

I'm trying to setup systemd-tool to be able to remotely unlock my headless system via ssh. I am trying to achieve the simplest solution possible, and wish to add it to the wiki as this project is amazing, but a bit hard to figure out how to use.

The setup is as such: ``` NAME FS LABEL TYPE /dev/sdX1 FAT32 boot ef00 /dev/sdX2 LUKS crypt 8308 - /dev/mapper/crypt LVM lvm - /dev/lvm/root BTRFS root - /dev/lvm/swap SWAP swap ``` ``` [initramfs]/etc/crypttab crypt UUID= none luks ``` ``` [initramfs]/etc/fstab /dev/lvm/root /sysroot auto x-systemd.device-timeout=9999h 0 1 /dev/lvm/swap none swap x-systemd.device-timeout=9999h 0 0 ``` ``` /etc/mkinitcpio.conf HOOKS=(base keyboard autodetect modconf block filesystems fsck systemd systemd-tool) ``` Setup before mkinitcpio -P: ``` Install: mkinitcpio-systemd-tool, busybox, cryptsetup, openssh, tinyssh, tinyssh-convert, mc, lvm2, btrfs-progs Run: ssh-keygen -A Write ssh pubkey to /root/.ssh/authorized_keys ``` Enabled services: ``` initrd-cryptsetup.path initrd-tinysshd initrd-debug-progs initrd-sysroot-mount ``` Bootloader: systemd-boot ``` title Arch Linux linux /vmlinuz-linux initrd /intel-ucode.img initrd /initramfs-linux.img options resume=/dev/nodelvm/swap ``` I'm able to decrypt the disk via the console or via SSH without issues. However, below is the resulting log. ``` [ OK ] Found device crypt Starting Cryptography setup for crypt... secret> [ OK ] Finished Cryptography Setup for crypt. [ OK ] Reached target Local Encrypted Volumes. [ TIME ] Timed out waiting for device /dev/gpt-auto-root. [DEPEND] Dependency failed for Initrd Root Device. ```

Does anyone know why the lvm volumes are not being found/mounted successfully?

Andrei-Pozolotin commented 4 years ago

is it safe to assume that past user cases did not help: https://github.com/random-archer/mkinitcpio-systemd-tool/wiki https://github.com/random-archer/mkinitcpio-systemd-tool/wiki/Case%3A-Sysroot-on-Btrfs etc?

kittydoor commented 4 years ago

I had read through the user cases and all relevant issues I could find before posting, and that's how I was able to puzzle things so far. After doing more investigation once I managed to get ssh access, I noticed that lvmdiskscan was missing. Adding the sd-lvm2 hook between systemd and systemd-tool fixed the issue! Tbh, it is not extremely clear to me how everything chains together and what causes the lvm scan to happen, why the delay occues after decrypting before boot continues (right after the message "Finished LVM2 PV scan on device 254:0") etc. But those are mostly from my lack of familiarity with the systemd boot process I'm sure.

Would there be any interest in me writing a user case in the wiki here for this specific setup?

Andrei-Pozolotin commented 4 years ago

Adding the sd-lvm2 hook between systemd and systemd-tool fixed the issue

you mean you have live working config now?

from my lack of familiarity with the systemd boot process

I assume this is now part of that "familiarity"? https://www.freedesktop.org/software/systemd/man/bootup.html

Would there be any interest in me writing a user case in the wiki here for this specific setup?

if you have working setup - by all means, yes, please, yes :-)

kittydoor commented 4 years ago

https://github.com/random-archer/mkinitcpio-systemd-tool/wiki/Case%3A-Complete-BTRFS-Setup-%28step-by-step%29

Documentation done! Sorry for the two week delay, only now managed to get to it. If anything on the guide is unclear, please feel free to poke me so I can improve on it!

Andrei-Pozolotin commented 4 years ago

looks great, thank you so much!

kittydoor commented 4 years ago

Thank YOU for the incredible project! And going above and beyond to help improve the formatting :)