Hello everyone.
I'm trying to build a simple initramfs to boot my system, however I
can't seem to get udev/systemd/lvm to work well together.
When using dracut everything works fine, however my curiosity pushes me
to understand why I can't do it in a minimal script.
I am using systemd 257.8, and LVM2 2.03.34, both are built manually.
My first attempt, (busybox + lvm built statically and placed in the
initramfs):
mkdir -p /mnt/root
lvm vgchange -ay
mount /dev/test_vm/root /mnt/root
exec switch_root /mnt/root /sbin/init
This worked quite well except post-boot, udevadm reported
"SYSTEMD_READY=0" bit on all my LVM volumes, and I couldn't mount them
using .mount / .swap files (or even from fstab on boot, they caused
timeouts). Some research led me to think it could be because I wasn't
using udev or anything similar, which led me to...
Try the script that Linux From Scratch provides
(https://www.linuxfromscratch.org/blfs/view/systemd/postlfs/initramfs.html).
It copies the necessary binaries from the real system (and their shared
libraries using ldd) to the initramfs.
The relevant parts are:
udevd --daemon --resolve-names=never
udevadm trigger
udevadm settle
lvm vgchange -a y
The issue with this is that vgchange just.. hangs. Either in a vm
(qmemu) or baremetal.
I did find some posts about a possible deadlock between udev / vgchange,
but I couldn't really pinpoint the issue still.
Both of these are so close to working but I can't figure out why they
can't work without issues. Since dracut makes everything work perfectly,
this tells me that my systemd/lvm/udev setup *can* work, it might just
be missing something and I don't know what it could be.
I understand I haven't posted a lot of details, I am not certain what
would be needed to debug this.
Thanks in advance :)