Gentoo Archives: gentoo-user

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

Replies

Subject Author
Re: [gentoo-user] difficulties with lvm2+systemd+grub2 Michael Mair-Keimberger <m.mairkeimberger@×××××.com>