Sanity check: systemd works with LVM2 root volume?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Sanity check: systemd works with LVM2 root volume?

Steven Lembark

Assuing the kernel has anything required to start up built in (i.e.,
no modules are required to boot, mount the root, switch root, or
mount any volumes described in /etc/fstab, access any resources
used for anything started via openrc or systemd), lvm.conf includes
"use_lvmetad = 1" in both the initrd and vg00/root.

I've tried tracing the logic produced by dracut to see why it failed,
but at over 1000 lines I do not have time to verify its logic and see
where it failed; ditto genkernel: there is too much logic to ignore
checking modules that don't exist because they are in the kernel.

Looking at:

    <https://wiki.gentoo.org/wiki/Systemd>

I've verified that the options are set (including choosing systemd
as the init), /run is there, /mtab is what is should be, GRUB is
updated.

The example below works perfectly with openrc, fails with systemd
(along with dracut results).

Q: What are the minimum steps/configuration required to set up and
   switch_root to systemd?

thanks

#!/bin/busybox sh

root='/mnt/root';
init='/sbin/init';

/bin/busybox --install -s;

mount /sys;
mount /proc;

lvm vgscan   -v;
lvm vgchange -v -a y;

mount /dev/vg00/root $root;

for i in $root/$init $root/usr $root/usr/bin
do
    # drop to shell if the root filesystem is botched.

    [ -e $i ] || exec /bin/busybox sh;
done

# seems bootable: init is there and /usr is mounted.

exec switch_root $root $init;

--
Steven Lembark                                           3646 Flora Pl
Workhorse Computing                                 St Louis, MO 63110
[hidden email]                                    +1 888 359 3508

Reply | Threaded
Open this post in threaded view
|

Re: Sanity check: systemd works with LVM2 root volume?

Rich Freeman
On Mon, Nov 30, 2015 at 12:24 PM, Steven Lembark <[hidden email]> wrote:
>
> I've tried tracing the logic produced by dracut to see why it failed,
> but at over 1000 lines I do not have time to verify its logic and see
> where it failed; ditto genkernel: there is too much logic to ignore
> checking modules that don't exist because they are in the kernel.
>

Did you try enabling debug output on dracut and an emergency shell?
The debug output is quite verbose in general and tends to give you a
good idea of where the problem lies (worst case you can add more
output if the specific function lacks it).  You can then try running
commands from the emergency shell to get root mounted and see if that
works, which will give you an idea of what is needed to fix the
problem.

As long as you mount the root on whatever mount point it creates
(/sysroot or something like that) and exit the shell, dracut will
attempt to complete the boot using the new root.

Oh, one other gotcha with dracut is that you need a valid /etc/fstab
for your root partition.  Since root is typically not mounted with
fstab with other initramfs systems sometimes it gets neglected.
Dracut attempts to mount it using its internal configuration, and then
remount it using the settings in /etc/fstab.  If you have a really
tricky setup there is also an fstab.sys module (or something along
those lines) that lets you create a special initramfs fstab in /etc
which contains just filesystems that need to be mounted early - dracut
embeds this file inside the initramfs and will mount everything it in
before launching init so it is useful if something like /sbin or
/usr/lib or whatever is on its own mountpoint).


--
Rich