Gentoo Archives: gentoo-user

From: covici@××××××××××.com
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] difficulties with lvm2+systemd+grub2
Date: Wed, 12 Nov 2014 11:44:39
Message-Id: 18642.1415792667@ccs.covici.com
In Reply to: Re: [gentoo-user] difficulties with lvm2+systemd+grub2 by Michael Mair-Keimberger
1 Michael Mair-Keimberger <m.mairkeimberger@×××××.com> wrote:
2
3 > On Tue, Nov 11, 2014 at 05:13:16PM -0500, covici@××××××××××.com wrote:
4 > > Michael Mair-Keimberger <m.mairkeimberger@×××××.com> wrote:
5 > >
6 > > > Hi List,
7 > > >
8 > > > Today I've started to play around with systemd but so far I couldn't get
9 > > > it to boot. I've followed the how to from the gentoo wiki [1], but I
10 > > > stuck somehow.
11 > > >
12 > > > My configuration:
13 > > > rootfs is on lvm2 (no encryption or raid). I just use it for being able
14 > > > creating snapshot/backups of the running system.
15 > > > Grub is on /dev/sda2 which is a simple ext2 partition with a custom
16 > > > grub.cfg. A Grub entry looks like that:
17 > > >
18 > > > ###
19 > > > menuentry 'gentoo amd64 gnome' {
20 > > > linux /gentoo-3.16.5-n lvm=gentoo_amd64_gnome
21 > > > initrd /initrd.cpio.gz
22 > > > }
23 > > > ###
24 > > >
25 > > > Don't get confused about the "lvm" flag. This just get passed to my very
26 > > > simple custom initramfs which looks like this:
27 > > >
28 > > > ###
29 > > > #!/bin/busybox sh
30 > > >
31 > > > cmdline() {
32 > > > local value
33 > > > value=" $(cat /proc/cmdline) "
34 > > > value="${value##* $1=}"
35 > > > value="${value%% *}"
36 > > > [ "$value" != "" ] && echo "$value"
37 > > > }
38 > > > # Mount the /proc and /sys filesystems.
39 > > > mount -t proc none /proc
40 > > > mount -t sysfs none /sys
41 > > > mount -t devtmpfs none /dev
42 > > >
43 > > > lvm vgscan
44 > > > lvm vgchange -ay vg0
45 > > > lvm vgscan --mknodes
46 > > >
47 > > > # Mount the root filesystem.
48 > > > mount -o ro /dev/mapper/vg0-$(cmdline lvm) /mnt/root
49 > > >
50 > > > # Clean up.
51 > > > umount /proc
52 > > > umount /sys
53 > > > umount /dev
54 > > >
55 > > > # Boot the real thing.
56 > > > exec switch_root /mnt/root /sbin/init
57 > > > ###
58 > > >
59 > > > So far this works great for me. However, with systemd I had some
60 > > > difficulties how to correctly configure the system and grub2 in order to
61 > > > boot with systemd.
62 > > >
63 > > > This is what i did so far:
64 > > >
65 > > > For systemd i've created a new initramfs with genkernel and changed the
66 > > > grub config like the following entry:
67 > > >
68 > > > ###
69 > > > menuentry 'gentoo amd64 gnome systemd' {
70 > > > linux /gentoo-3.16.5-n root=UUID=1eb94a2b-40d7-4556-9102-0320efd04adc init=/usr/lib/systemd/systemd
71 > > > initrd /initramfs-genkernel-x86_64-3.16.5-gentoo
72 > > > }
73 > > > ###
74 > > >
75 > > > Systemd installation went without problems (it's a base system without
76 > > > any wm's installed atm), but even though the grub2 changes were quite
77 > > > easy and I've used the genkernel initramfs instead of mine I still get a
78 > > > kernel panic on boot (have a look at the attached picture).
79 > > > I've also checked the kernel config for having the required systemd
80 > > > configurations enabled.
81 > > >
82 > > > Anyone has some ideas what might be wrong?
83 > > >
84 > > > Furthermore I've also have some questions about lvm2+systemd. Hope
85 > > > someone can give me some answers :)
86 > > >
87 > > > First of all, with systemd installed I can't install lvm2 with the
88 > > > static use flag anymore, which is mandatory for being able using it for
89 > > > a initramfs. Why isn't that possible? How can I use the lvm binaries for
90 > > > my initramfs?
91 > > >
92 > > > This lead me to my second question. At the wiki, the only way to create
93 > > > an initramfs for systemd was with genkernel (genkernel --udev --lvm).
94 > > > While the command itself is pretty useless (it's `genkernel --udev --lvm
95 > > > initramfs` if you want to create the initramfs -> is this a bug??) i
96 > > > also would like to use my own initramfs.
97 > > > What changes do i have to make in my own initramfs for being able
98 > > > booting systemd from it?
99 > >
100 > > I would use dracut to generate the initramfs and use rd.lvm.vg= to
101 > > activate your volume group and specify the init as the exact location
102 > > of the systemd binary -- then you don't need static or anything, dracut
103 > > will automatically put in the appropriate libraries, and also check the
104 > > file systems upon boot. Much better if you need to use systemd.
105 > >
106 > > Hope this helps.
107 >
108 > Dracut was already mentioned. I'll give it a try later that day. Regarding your
109 > "rd.lvm.vg=" flag. I guess should be put into the grub2 entry, shouldn't
110 > it?
111 >
112 > Anyway, thanks for sharing :)
113
114 Yep, that is where it should go and it seems to work nicely. I had a
115 lot of work to find that I needed that, otherwise the lvm volumes were
116 not there and my root would not mount at all.
117
118 --
119 Your life is like a penny. You're going to lose it. The question is:
120 How do
121 you spend it?
122
123 John Covici
124 covici@××××××××××.com