Okay I have figured it out.

It was something "hidden" in the udev rules, and a mistake on my part. LFS doesn't seem to follow the "everything into /usr/bin", and so they were moving "lvm" into /usr/sbin (a separate folder).

Inspecting the udev rules led me to notice that it was calling "/usr/bin/lvm", which was obviously not there.

Symlinking /usr/sbin -> /usr/bin in the initramfs makes everything work.

Sorry for the noise, if anything it may help someone in the future :')

On 8/28/2025 5:13 AM, Zdenek Kabelac wrote:
Dne 27. 08. 25 v 22:03 Jason Pleau napsal(a):
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.

Hi


Not that I'd think you are doing 'smart' thing, since the setup looks really suspicious, but here are 2 basic advises:

1. If you run any lvm2 command - there can be great help if you add '-vvvv' so we can at least see for what it's waiting for.

2. Since the udevd setup on your box is probably non-working correctly - there is large probability that lvm2 just hangs waiting for 'cookie' confirmation which happens through our udev rule processing  (your initramfs shall have these udev rules installed).     lvm2 may as well work without udev - see the option -  '--noudevsync'   and /etc/lvm/lvm.conf setting activation/udev_sync and activation/verify_udev_operations.

However you've been warned these settings are rather for skilled admins who know what they are doing and why - the fact it may 'unstuck' the command to proceed further, doesn't really make it right....

Regards

Zdenek

Reply via email to