* [gentoo-user] difficulties with lvm2+systemd+grub2 @ 2014-11-11 20:56 Michael Mair-Keimberger 2014-11-11 21:44 ` Stefan G. Weichinger ` (3 more replies) 0 siblings, 4 replies; 16+ messages in thread From: Michael Mair-Keimberger @ 2014-11-11 20:56 UTC (permalink / raw To: gentoo user mailing list [-- Attachment #1.1: Type: text/plain, Size: 3100 bytes --] Hi List, Today I've started to play around with systemd but so far I couldn't get it to boot. I've followed the how to from the gentoo wiki [1], but I stuck somehow. My configuration: rootfs is on lvm2 (no encryption or raid). I just use it for being able creating snapshot/backups of the running system. Grub is on /dev/sda2 which is a simple ext2 partition with a custom grub.cfg. A Grub entry looks like that: ### menuentry 'gentoo amd64 gnome' { linux /gentoo-3.16.5-n lvm=gentoo_amd64_gnome initrd /initrd.cpio.gz } ### Don't get confused about the "lvm" flag. This just get passed to my very simple custom initramfs which looks like this: ### #!/bin/busybox sh cmdline() { local value value=" $(cat /proc/cmdline) " value="${value##* $1=}" value="${value%% *}" [ "$value" != "" ] && echo "$value" } # Mount the /proc and /sys filesystems. mount -t proc none /proc mount -t sysfs none /sys mount -t devtmpfs none /dev lvm vgscan lvm vgchange -ay vg0 lvm vgscan --mknodes # Mount the root filesystem. mount -o ro /dev/mapper/vg0-$(cmdline lvm) /mnt/root # Clean up. umount /proc umount /sys umount /dev # Boot the real thing. exec switch_root /mnt/root /sbin/init ### So far this works great for me. However, with systemd I had some difficulties how to correctly configure the system and grub2 in order to boot with systemd. This is what i did so far: For systemd i've created a new initramfs with genkernel and changed the grub config like the following entry: ### menuentry 'gentoo amd64 gnome systemd' { linux /gentoo-3.16.5-n root=UUID=1eb94a2b-40d7-4556-9102-0320efd04adc init=/usr/lib/systemd/systemd initrd /initramfs-genkernel-x86_64-3.16.5-gentoo } ### Systemd installation went without problems (it's a base system without any wm's installed atm), but even though the grub2 changes were quite easy and I've used the genkernel initramfs instead of mine I still get a kernel panic on boot (have a look at the attached picture). I've also checked the kernel config for having the required systemd configurations enabled. Anyone has some ideas what might be wrong? Furthermore I've also have some questions about lvm2+systemd. Hope someone can give me some answers :) First of all, with systemd installed I can't install lvm2 with the static use flag anymore, which is mandatory for being able using it for a initramfs. Why isn't that possible? How can I use the lvm binaries for my initramfs? This lead me to my second question. At the wiki, the only way to create an initramfs for systemd was with genkernel (genkernel --udev --lvm). While the command itself is pretty useless (it's `genkernel --udev --lvm initramfs` if you want to create the initramfs -> is this a bug??) i also would like to use my own initramfs. What changes do i have to make in my own initramfs for being able booting systemd from it? Thx :) [1] http://wiki.gentoo.org/wiki/Systemd -- greetings Michael Mair-Keimberger [-- Attachment #1.2: systemd.jpg --] [-- Type: image/jpeg, Size: 581501 bytes --] [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-11 20:56 [gentoo-user] difficulties with lvm2+systemd+grub2 Michael Mair-Keimberger @ 2014-11-11 21:44 ` Stefan G. Weichinger 2014-11-12 8:22 ` Michael Mair-Keimberger 2014-11-11 21:47 ` Jc García ` (2 subsequent siblings) 3 siblings, 1 reply; 16+ messages in thread From: Stefan G. Weichinger @ 2014-11-11 21:44 UTC (permalink / raw To: gentoo-user Am 11.11.2014 um 21:56 schrieb Michael Mair-Keimberger: > Don't get confused about the "lvm" flag. This just get passed to my very > simple custom initramfs Why not try dracut for creating your initrd? I spent *lots* of time around lvm/mdadm with systemd and grub2 back then ... What does your own initramfs do that dracut won't do? - Aside from that: We don't see your kernel-config. Did you check for the requirements systemd has and recompile your kernel accordingly? Does your new menuentry boot without the init= part? - Just some generic thoughts, nothing specific, sorry. Stefan ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-11 21:44 ` Stefan G. Weichinger @ 2014-11-12 8:22 ` Michael Mair-Keimberger 0 siblings, 0 replies; 16+ messages in thread From: Michael Mair-Keimberger @ 2014-11-12 8:22 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 1297 bytes --] On Tue, Nov 11, 2014 at 10:44:36PM +0100, Stefan G. Weichinger wrote: > Am 11.11.2014 um 21:56 schrieb Michael Mair-Keimberger: > > > Don't get confused about the "lvm" flag. This just get passed to my very > > simple custom initramfs > > Why not try dracut for creating your initrd? > > I spent *lots* of time around lvm/mdadm with systemd and grub2 back then ... > > What does your own initramfs do that dracut won't do? > There's no specific reason why I use my own initrd. Maybe just curiosity - I just want to know what my initrd is really doing ;) I'll try dracut. If it's working I still can look into it's init script to find out what exactly is wrong with my custom one. > - > > Aside from that: > > We don't see your kernel-config. Did you check for the requirements > systemd has and recompile your kernel accordingly? > Yeah, i've checked my kernel config (even wrote that). I've just followed the wiki howto regarding kernel config :) > Does your new menuentry boot without the init= part? > Hmm, not sure if i've tried that. I'll give it a try when i'm back home. > - > > Just some generic thoughts, nothing specific, sorry. Thanks anyway, dracut is a starting point. > > Stefan > > -- greetings Michael Mair-Keimberger [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-11 20:56 [gentoo-user] difficulties with lvm2+systemd+grub2 Michael Mair-Keimberger 2014-11-11 21:44 ` Stefan G. Weichinger @ 2014-11-11 21:47 ` Jc García 2014-11-12 8:25 ` Michael Mair-Keimberger 2014-11-11 22:13 ` covici 2014-11-12 1:03 ` wraeth 3 siblings, 1 reply; 16+ messages in thread From: Jc García @ 2014-11-11 21:47 UTC (permalink / raw To: gentoo-user 2014-11-11 14:56 GMT-06:00 Michael Mair-Keimberger <m.mairkeimberger@gmail.com>: > This lead me to my second question. At the wiki, the only way to create > an initramfs for systemd was with genkernel (genkernel --udev --lvm). > While the command itself is pretty useless (it's `genkernel --udev --lvm > initramfs` if you want to create the initramfs -> is this a bug??) i > also would like to use my own initramfs. > What changes do i have to make in my own initramfs for being able > booting systemd from it? > Did you used genkernel-next?, also the recommendation on this list for generating initramfs for systemd is dracut, you should give that a try. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-11 21:47 ` Jc García @ 2014-11-12 8:25 ` Michael Mair-Keimberger 0 siblings, 0 replies; 16+ messages in thread From: Michael Mair-Keimberger @ 2014-11-12 8:25 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 920 bytes --] On Tue, Nov 11, 2014 at 03:47:49PM -0600, Jc García wrote: > 2014-11-11 14:56 GMT-06:00 Michael Mair-Keimberger <m.mairkeimberger@gmail.com>: > > > This lead me to my second question. At the wiki, the only way to create > > an initramfs for systemd was with genkernel (genkernel --udev --lvm). > > While the command itself is pretty useless (it's `genkernel --udev --lvm > > initramfs` if you want to create the initramfs -> is this a bug??) i > > also would like to use my own initramfs. > > What changes do i have to make in my own initramfs for being able > > booting systemd from it? > > > > Did you used genkernel-next?, also the recommendation on this list for > generating initramfs for systemd is dracut, you should give that a > try. > Sorry, i wasn't specific enough on that. Yes, i've used genkernel-next and I'll give dracut a try. Thanks! -- greetings Michael Mair-Keimberger [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-11 20:56 [gentoo-user] difficulties with lvm2+systemd+grub2 Michael Mair-Keimberger 2014-11-11 21:44 ` Stefan G. Weichinger 2014-11-11 21:47 ` Jc García @ 2014-11-11 22:13 ` covici 2014-11-12 9:47 ` Michael Mair-Keimberger 2014-11-12 1:03 ` wraeth 3 siblings, 1 reply; 16+ messages in thread From: covici @ 2014-11-11 22:13 UTC (permalink / raw To: gentoo-user Michael Mair-Keimberger <m.mairkeimberger@gmail.com> wrote: > Hi List, > > Today I've started to play around with systemd but so far I couldn't get > it to boot. I've followed the how to from the gentoo wiki [1], but I > stuck somehow. > > My configuration: > rootfs is on lvm2 (no encryption or raid). I just use it for being able > creating snapshot/backups of the running system. > Grub is on /dev/sda2 which is a simple ext2 partition with a custom > grub.cfg. A Grub entry looks like that: > > ### > menuentry 'gentoo amd64 gnome' { > linux /gentoo-3.16.5-n lvm=gentoo_amd64_gnome > initrd /initrd.cpio.gz > } > ### > > Don't get confused about the "lvm" flag. This just get passed to my very > simple custom initramfs which looks like this: > > ### > #!/bin/busybox sh > > cmdline() { > local value > value=" $(cat /proc/cmdline) " > value="${value##* $1=}" > value="${value%% *}" > [ "$value" != "" ] && echo "$value" > } > # Mount the /proc and /sys filesystems. > mount -t proc none /proc > mount -t sysfs none /sys > mount -t devtmpfs none /dev > > lvm vgscan > lvm vgchange -ay vg0 > lvm vgscan --mknodes > > # Mount the root filesystem. > mount -o ro /dev/mapper/vg0-$(cmdline lvm) /mnt/root > > # Clean up. > umount /proc > umount /sys > umount /dev > > # Boot the real thing. > exec switch_root /mnt/root /sbin/init > ### > > So far this works great for me. However, with systemd I had some > difficulties how to correctly configure the system and grub2 in order to > boot with systemd. > > This is what i did so far: > > For systemd i've created a new initramfs with genkernel and changed the > grub config like the following entry: > > ### > menuentry 'gentoo amd64 gnome systemd' { > linux /gentoo-3.16.5-n root=UUID=1eb94a2b-40d7-4556-9102-0320efd04adc init=/usr/lib/systemd/systemd > initrd /initramfs-genkernel-x86_64-3.16.5-gentoo > } > ### > > Systemd installation went without problems (it's a base system without > any wm's installed atm), but even though the grub2 changes were quite > easy and I've used the genkernel initramfs instead of mine I still get a > kernel panic on boot (have a look at the attached picture). > I've also checked the kernel config for having the required systemd > configurations enabled. > > Anyone has some ideas what might be wrong? > > Furthermore I've also have some questions about lvm2+systemd. Hope > someone can give me some answers :) > > First of all, with systemd installed I can't install lvm2 with the > static use flag anymore, which is mandatory for being able using it for > a initramfs. Why isn't that possible? How can I use the lvm binaries for > my initramfs? > > This lead me to my second question. At the wiki, the only way to create > an initramfs for systemd was with genkernel (genkernel --udev --lvm). > While the command itself is pretty useless (it's `genkernel --udev --lvm > initramfs` if you want to create the initramfs -> is this a bug??) i > also would like to use my own initramfs. > What changes do i have to make in my own initramfs for being able > booting systemd from it? I would use dracut to generate the initramfs and use rd.lvm.vg= to activate your volume group and specify the init as the exact location of the systemd binary -- then you don't need static or anything, dracut will automatically put in the appropriate libraries, and also check the file systems upon boot. Much better if you need to use systemd. Hope this helps. -- Your life is like a penny. You're going to lose it. The question is: How do you spend it? John Covici covici@ccs.covici.com ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-11 22:13 ` covici @ 2014-11-12 9:47 ` Michael Mair-Keimberger 2014-11-12 10:19 ` Stefan G. Weichinger 2014-11-12 11:44 ` covici 0 siblings, 2 replies; 16+ messages in thread From: Michael Mair-Keimberger @ 2014-11-12 9:47 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 4323 bytes --] On Tue, Nov 11, 2014 at 05:13:16PM -0500, covici@ccs.covici.com wrote: > Michael Mair-Keimberger <m.mairkeimberger@gmail.com> wrote: > > > Hi List, > > > > Today I've started to play around with systemd but so far I couldn't get > > it to boot. I've followed the how to from the gentoo wiki [1], but I > > stuck somehow. > > > > My configuration: > > rootfs is on lvm2 (no encryption or raid). I just use it for being able > > creating snapshot/backups of the running system. > > Grub is on /dev/sda2 which is a simple ext2 partition with a custom > > grub.cfg. A Grub entry looks like that: > > > > ### > > menuentry 'gentoo amd64 gnome' { > > linux /gentoo-3.16.5-n lvm=gentoo_amd64_gnome > > initrd /initrd.cpio.gz > > } > > ### > > > > Don't get confused about the "lvm" flag. This just get passed to my very > > simple custom initramfs which looks like this: > > > > ### > > #!/bin/busybox sh > > > > cmdline() { > > local value > > value=" $(cat /proc/cmdline) " > > value="${value##* $1=}" > > value="${value%% *}" > > [ "$value" != "" ] && echo "$value" > > } > > # Mount the /proc and /sys filesystems. > > mount -t proc none /proc > > mount -t sysfs none /sys > > mount -t devtmpfs none /dev > > > > lvm vgscan > > lvm vgchange -ay vg0 > > lvm vgscan --mknodes > > > > # Mount the root filesystem. > > mount -o ro /dev/mapper/vg0-$(cmdline lvm) /mnt/root > > > > # Clean up. > > umount /proc > > umount /sys > > umount /dev > > > > # Boot the real thing. > > exec switch_root /mnt/root /sbin/init > > ### > > > > So far this works great for me. However, with systemd I had some > > difficulties how to correctly configure the system and grub2 in order to > > boot with systemd. > > > > This is what i did so far: > > > > For systemd i've created a new initramfs with genkernel and changed the > > grub config like the following entry: > > > > ### > > menuentry 'gentoo amd64 gnome systemd' { > > linux /gentoo-3.16.5-n root=UUID=1eb94a2b-40d7-4556-9102-0320efd04adc init=/usr/lib/systemd/systemd > > initrd /initramfs-genkernel-x86_64-3.16.5-gentoo > > } > > ### > > > > Systemd installation went without problems (it's a base system without > > any wm's installed atm), but even though the grub2 changes were quite > > easy and I've used the genkernel initramfs instead of mine I still get a > > kernel panic on boot (have a look at the attached picture). > > I've also checked the kernel config for having the required systemd > > configurations enabled. > > > > Anyone has some ideas what might be wrong? > > > > Furthermore I've also have some questions about lvm2+systemd. Hope > > someone can give me some answers :) > > > > First of all, with systemd installed I can't install lvm2 with the > > static use flag anymore, which is mandatory for being able using it for > > a initramfs. Why isn't that possible? How can I use the lvm binaries for > > my initramfs? > > > > This lead me to my second question. At the wiki, the only way to create > > an initramfs for systemd was with genkernel (genkernel --udev --lvm). > > While the command itself is pretty useless (it's `genkernel --udev --lvm > > initramfs` if you want to create the initramfs -> is this a bug??) i > > also would like to use my own initramfs. > > What changes do i have to make in my own initramfs for being able > > booting systemd from it? > > I would use dracut to generate the initramfs and use rd.lvm.vg= to > activate your volume group and specify the init as the exact location > of the systemd binary -- then you don't need static or anything, dracut > will automatically put in the appropriate libraries, and also check the > file systems upon boot. Much better if you need to use systemd. > > Hope this helps. Dracut was already mentioned. I'll give it a try later that day. Regarding your "rd.lvm.vg=" flag. I guess should be put into the grub2 entry, shouldn't it? Anyway, thanks for sharing :) > > -- > Your life is like a penny. You're going to lose it. The question is: > How do > you spend it? > > John Covici > covici@ccs.covici.com > -- greetings Michael Mair-Keimberger [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-12 9:47 ` Michael Mair-Keimberger @ 2014-11-12 10:19 ` Stefan G. Weichinger 2014-11-12 11:44 ` covici 1 sibling, 0 replies; 16+ messages in thread From: Stefan G. Weichinger @ 2014-11-12 10:19 UTC (permalink / raw To: gentoo-user Am 12.11.2014 um 10:47 schrieb Michael Mair-Keimberger: > Dracut was already mentioned. I'll give it a try later that day. > Regarding your "rd.lvm.vg=" flag. I guess should be put into the > grub2 entry, shouldn't it? Yes, in the same line where you add the init= parameter. You might add it to your /etc/default/grub file, into GRUB_CMDLINE_LINUX= ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-12 9:47 ` Michael Mair-Keimberger 2014-11-12 10:19 ` Stefan G. Weichinger @ 2014-11-12 11:44 ` covici 1 sibling, 0 replies; 16+ messages in thread From: covici @ 2014-11-12 11:44 UTC (permalink / raw To: gentoo-user Michael Mair-Keimberger <m.mairkeimberger@gmail.com> wrote: > On Tue, Nov 11, 2014 at 05:13:16PM -0500, covici@ccs.covici.com wrote: > > Michael Mair-Keimberger <m.mairkeimberger@gmail.com> wrote: > > > > > Hi List, > > > > > > Today I've started to play around with systemd but so far I couldn't get > > > it to boot. I've followed the how to from the gentoo wiki [1], but I > > > stuck somehow. > > > > > > My configuration: > > > rootfs is on lvm2 (no encryption or raid). I just use it for being able > > > creating snapshot/backups of the running system. > > > Grub is on /dev/sda2 which is a simple ext2 partition with a custom > > > grub.cfg. A Grub entry looks like that: > > > > > > ### > > > menuentry 'gentoo amd64 gnome' { > > > linux /gentoo-3.16.5-n lvm=gentoo_amd64_gnome > > > initrd /initrd.cpio.gz > > > } > > > ### > > > > > > Don't get confused about the "lvm" flag. This just get passed to my very > > > simple custom initramfs which looks like this: > > > > > > ### > > > #!/bin/busybox sh > > > > > > cmdline() { > > > local value > > > value=" $(cat /proc/cmdline) " > > > value="${value##* $1=}" > > > value="${value%% *}" > > > [ "$value" != "" ] && echo "$value" > > > } > > > # Mount the /proc and /sys filesystems. > > > mount -t proc none /proc > > > mount -t sysfs none /sys > > > mount -t devtmpfs none /dev > > > > > > lvm vgscan > > > lvm vgchange -ay vg0 > > > lvm vgscan --mknodes > > > > > > # Mount the root filesystem. > > > mount -o ro /dev/mapper/vg0-$(cmdline lvm) /mnt/root > > > > > > # Clean up. > > > umount /proc > > > umount /sys > > > umount /dev > > > > > > # Boot the real thing. > > > exec switch_root /mnt/root /sbin/init > > > ### > > > > > > So far this works great for me. However, with systemd I had some > > > difficulties how to correctly configure the system and grub2 in order to > > > boot with systemd. > > > > > > This is what i did so far: > > > > > > For systemd i've created a new initramfs with genkernel and changed the > > > grub config like the following entry: > > > > > > ### > > > menuentry 'gentoo amd64 gnome systemd' { > > > linux /gentoo-3.16.5-n root=UUID=1eb94a2b-40d7-4556-9102-0320efd04adc init=/usr/lib/systemd/systemd > > > initrd /initramfs-genkernel-x86_64-3.16.5-gentoo > > > } > > > ### > > > > > > Systemd installation went without problems (it's a base system without > > > any wm's installed atm), but even though the grub2 changes were quite > > > easy and I've used the genkernel initramfs instead of mine I still get a > > > kernel panic on boot (have a look at the attached picture). > > > I've also checked the kernel config for having the required systemd > > > configurations enabled. > > > > > > Anyone has some ideas what might be wrong? > > > > > > Furthermore I've also have some questions about lvm2+systemd. Hope > > > someone can give me some answers :) > > > > > > First of all, with systemd installed I can't install lvm2 with the > > > static use flag anymore, which is mandatory for being able using it for > > > a initramfs. Why isn't that possible? How can I use the lvm binaries for > > > my initramfs? > > > > > > This lead me to my second question. At the wiki, the only way to create > > > an initramfs for systemd was with genkernel (genkernel --udev --lvm). > > > While the command itself is pretty useless (it's `genkernel --udev --lvm > > > initramfs` if you want to create the initramfs -> is this a bug??) i > > > also would like to use my own initramfs. > > > What changes do i have to make in my own initramfs for being able > > > booting systemd from it? > > > > I would use dracut to generate the initramfs and use rd.lvm.vg= to > > activate your volume group and specify the init as the exact location > > of the systemd binary -- then you don't need static or anything, dracut > > will automatically put in the appropriate libraries, and also check the > > file systems upon boot. Much better if you need to use systemd. > > > > Hope this helps. > > Dracut was already mentioned. I'll give it a try later that day. Regarding your > "rd.lvm.vg=" flag. I guess should be put into the grub2 entry, shouldn't > it? > > Anyway, thanks for sharing :) Yep, that is where it should go and it seems to work nicely. I had a lot of work to find that I needed that, otherwise the lvm volumes were not there and my root would not mount at all. -- Your life is like a penny. You're going to lose it. The question is: How do you spend it? John Covici covici@ccs.covici.com ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-11 20:56 [gentoo-user] difficulties with lvm2+systemd+grub2 Michael Mair-Keimberger ` (2 preceding siblings ...) 2014-11-11 22:13 ` covici @ 2014-11-12 1:03 ` wraeth 2014-11-12 9:42 ` Michael Mair-Keimberger 3 siblings, 1 reply; 16+ messages in thread From: wraeth @ 2014-11-12 1:03 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 2783 bytes --] On Tue, Nov 11, 2014 at 09:56:09PM +0100, Michael Mair-Keimberger wrote: > Today I've started to play around with systemd but so far I couldn't get > it to boot. I've followed the how to from the gentoo wiki [1], but I > stuck somehow. I found systemd to be rather tricky to implement on some of my systems, but this was a while ago and was in a more complex configuration that you're using (though as most people are suggesting, I used dracut to generate my initrd). I would also suggest to use either dracut or genkernel-next to generate an initramfs if you wanted to go down that path. Note that sys-kernel/genkernel (as opposed to sys-kernel/genkernel-next) can have issues with systemd (the last time I tried it it complained about systemd and suggested using genkernel-next). If you would prefer a hand-rolled one, I can't offer much, but as I think has already been suggested, one key point is to call the correct binary. The systemd binary itself is /usr/lib/systemd/systemd, though calling /sbin/init may work if that's configured in such a way as to launch systemd. The other point I might add is that my system, which uses dracut, has systemd launched with some specific arguments: ps -fp 1 UID PID PPID C STIME TTY TIME CMD root 1 0 0 11:31 ? 00:00:00 /usr/lib/systemd/systemd --switched-root --system --deserialize 18 This may be relevant when creating your own initramfs. > First of all, with systemd installed I can't install lvm2 with the > static use flag anymore, which is mandatory for being able using it for > a initramfs. Why isn't that possible? How can I use the lvm binaries for > my initramfs? Again, as I think has been mentioned, the 'static' use flag is typically a shortcut for easily building an initrd. Provided you include all the dependencies of a given binary (as seen with `ldd /path/to/binary`) you don't need static binaries. > This lead me to my second question. At the wiki, the only way to create > an initramfs for systemd was with genkernel (genkernel --udev --lvm). > While the command itself is pretty useless (it's `genkernel --udev --lvm > initramfs` if you want to create the initramfs -> is this a bug??) i > also would like to use my own initramfs. I'm not sure what you mean by the command is useless and is a bug. Genkernel has multiple potential targets - 'all' for building the kernel and initrams, 'kernel' for the kernel binary and modules, 'initramfs' for just the initramfs image, etc. This command should generate an initramfs with the required components for systemd, udev and lvm. Hopefully some of this will help clear things up a little. Cheers. -- wraeth <wraeth@wraeth.id.au> GnuPG Key: B2D9F759 [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 213 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-12 1:03 ` wraeth @ 2014-11-12 9:42 ` Michael Mair-Keimberger 2014-11-12 10:07 ` Sam Jorna 0 siblings, 1 reply; 16+ messages in thread From: Michael Mair-Keimberger @ 2014-11-12 9:42 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 4134 bytes --] On Wed, Nov 12, 2014 at 12:03:04PM +1100, wraeth@wraeth.id.au wrote: > On Tue, Nov 11, 2014 at 09:56:09PM +0100, Michael Mair-Keimberger wrote: > > Today I've started to play around with systemd but so far I couldn't get > > it to boot. I've followed the how to from the gentoo wiki [1], but I > > stuck somehow. > > I found systemd to be rather tricky to implement on some of my systems, > but this was a while ago and was in a more complex configuration that > you're using (though as most people are suggesting, I used dracut to > generate my initrd). > > I would also suggest to use either dracut or genkernel-next to generate > an initramfs if you wanted to go down that path. Note that > sys-kernel/genkernel (as opposed to sys-kernel/genkernel-next) can have > issues with systemd (the last time I tried it it complained about > systemd and suggested using genkernel-next). > > If you would prefer a hand-rolled one, I can't offer much, but as I > think has already been suggested, one key point is to call the correct > binary. > > The systemd binary itself is /usr/lib/systemd/systemd, though calling > /sbin/init may work if that's configured in such a way as to launch > systemd. > Thanks for the detailed explanation. I wasn't specific enough on the genkernel part. I already used genkernel-next for generating the initramfs (which doesn't boot). However i'll give dracut a try, I guess if it works i still can extract dracut's initramfs and see what exaclty it does in order to boot with systemd. Maybe i could adopt that to my custom one as well. > The other point I might add is that my system, which uses dracut, has > systemd launched with some specific arguments: > > ps -fp 1 > UID PID PPID C STIME TTY TIME CMD > root 1 0 0 11:31 ? 00:00:00 > /usr/lib/systemd/systemd --switched-root --system --deserialize 18 > > This may be relevant when creating your own initramfs. Thanks, thats something i could try as well :) > > > First of all, with systemd installed I can't install lvm2 with the > > static use flag anymore, which is mandatory for being able using it for > > a initramfs. Why isn't that possible? How can I use the lvm binaries for > > my initramfs? > > Again, as I think has been mentioned, the 'static' use flag is typically > a shortcut for easily building an initrd. Provided you include all the > dependencies of a given binary (as seen with `ldd /path/to/binary`) you > don't need static binaries. Yeah, now i was digging a bit further into static binaries. If I insert the relevant libaries it should work too. :) However i was wondering why lvm2 shouldn't be able to build with the static flag on systemd. However that's not important any more, i'm just curious :) > > > This lead me to my second question. At the wiki, the only way to create > > an initramfs for systemd was with genkernel (genkernel --udev --lvm). > > While the command itself is pretty useless (it's `genkernel --udev --lvm > > initramfs` if you want to create the initramfs -> is this a bug??) i > > also would like to use my own initramfs. > > I'm not sure what you mean by the command is useless and is a bug. > Genkernel has multiple potential targets - 'all' for building the kernel > and initrams, 'kernel' for the kernel binary and modules, 'initramfs' > for just the initramfs image, etc. This command should generate an > initramfs with the required components for systemd, udev and lvm. Well, at the wiki it's written you should run: genkernel --udev --lvm in order to generate the initramfs. But, you already mentioned it, you need a target in order generate anything, but it isn't mentioned at the wiki. As i'm not familar with genkernel i was a bit confused about the command. I would suggest following for example: genkernel --udev --lvm [target] > > Hopefully some of this will help clear things up a little. Yes, of course. Many thanks :) > > Cheers. > -- > wraeth <wraeth@wraeth.id.au> > GnuPG Key: B2D9F759 -- greetings Michael Mair-Keimberger [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-12 9:42 ` Michael Mair-Keimberger @ 2014-11-12 10:07 ` Sam Jorna 2014-11-12 10:20 ` Stefan G. Weichinger 0 siblings, 1 reply; 16+ messages in thread From: Sam Jorna @ 2014-11-12 10:07 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 2453 bytes --] On Wed, Nov 12, 2014 at 10:42:28AM +0100, Michael Mair-Keimberger wrote: > On Wed, Nov 12, 2014 at 12:03:04PM +1100, wraeth@wraeth.id.au wrote: > > On Tue, Nov 11, 2014 at 09:56:09PM +0100, Michael Mair-Keimberger wrote: <snip> > systemd. Maybe i could adopt that to my custom one as well. </snip> Working examples are always nice :-) > > The other point I might add is that my system, which uses dracut, has > > systemd launched with some specific arguments: > > > > ps -fp 1 > > UID PID PPID C STIME TTY TIME CMD > > root 1 0 0 11:31 ? 00:00:00 > > /usr/lib/systemd/systemd --switched-root --system --deserialize 18 > > > > This may be relevant when creating your own initramfs. > > Thanks, thats something i could try as well :) I'm not sure of the relevancy (it was just an observation), and I'm not sure how the options (specifically --deserialize NN) is determined since another of my machines has /usr/lib/systemd/systemd --switched-root --system --deserialize 19 > > > First of all, with systemd installed I can't install lvm2 with the > > > static use flag anymore, which is mandatory for being able using it for > > > a initramfs. Why isn't that possible? How can I use the lvm binaries for > > > my initramfs? > > > > Again, as I think has been mentioned, the 'static' use flag is typically > > a shortcut for easily building an initrd. Provided you include all the > > dependencies of a given binary (as seen with `ldd /path/to/binary`) you > > don't need static binaries. > > Yeah, now i was digging a bit further into static binaries. If I insert the > relevant libaries it should work too. :) > However i was wondering why lvm2 shouldn't be able to build with the > static flag on systemd. However that's not important any more, i'm just > curious :) This *is* odd, but without a build log we can't really tell (unless someone else has encountered the issue too). > Well, at the wiki it's written you should run: > genkernel --udev --lvm > in order to generate the initramfs. But, you already mentioned it, you > need a target in order generate anything, but it isn't mentioned at the > wiki. > As i'm not familar with genkernel i was a bit confused about the > command. I would suggest following for example: > genkernel --udev --lvm [target] Fixed :-) Cheers. -- wraeth <wraeth@wraeth.id.au> GnuPG Key: B2D9F759 [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 213 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-12 10:07 ` Sam Jorna @ 2014-11-12 10:20 ` Stefan G. Weichinger 2014-11-14 18:43 ` Michael Mair-Keimberger 0 siblings, 1 reply; 16+ messages in thread From: Stefan G. Weichinger @ 2014-11-12 10:20 UTC (permalink / raw To: gentoo-user Am 12.11.2014 um 11:07 schrieb Sam Jorna: > On Wed, Nov 12, 2014 at 10:42:28AM +0100, Michael Mair-Keimberger > wrote: >> On Wed, Nov 12, 2014 at 12:03:04PM +1100, wraeth@wraeth.id.au >> wrote: >>> On Tue, Nov 11, 2014 at 09:56:09PM +0100, Michael >>> Mair-Keimberger wrote: > <snip> >> systemd. Maybe i could adopt that to my custom one as well. > </snip> > > Working examples are always nice :-) Around dracut and grub2 I remember a few bits, maybe they help. In /etc/dracut.conf I have (after discussion here): # dracut modules to omit omit_dracutmodules+="systemd" (this one means "don't build an instance of systemd *into* the initrd) # dracut modules to add to the default add_dracutmodules+="bash" # build initrd only to boot current hardware hostonly="yes" hostonly_cmdline="yes" I don't use lvm and sw-raid anymore, you might need: add_dracutmodules+="lvm bash mdraid" or so. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-12 10:20 ` Stefan G. Weichinger @ 2014-11-14 18:43 ` Michael Mair-Keimberger 2014-11-16 1:21 ` wraeth 0 siblings, 1 reply; 16+ messages in thread From: Michael Mair-Keimberger @ 2014-11-14 18:43 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 2445 bytes --] On Wed, Nov 12, 2014 at 11:20:53AM +0100, Stefan G. Weichinger wrote: > Am 12.11.2014 um 11:07 schrieb Sam Jorna: > > On Wed, Nov 12, 2014 at 10:42:28AM +0100, Michael Mair-Keimberger > > wrote: > >> On Wed, Nov 12, 2014 at 12:03:04PM +1100, wraeth@wraeth.id.au > >> wrote: > >>> On Tue, Nov 11, 2014 at 09:56:09PM +0100, Michael > >>> Mair-Keimberger wrote: > > <snip> > >> systemd. Maybe i could adopt that to my custom one as well. > > </snip> > > > > Working examples are always nice :-) > > Around dracut and grub2 I remember a few bits, maybe they help. > > In /etc/dracut.conf I have (after discussion here): > > # dracut modules to omit > omit_dracutmodules+="systemd" > > (this one means "don't build an instance of systemd *into* the initrd) > > # dracut modules to add to the default > add_dracutmodules+="bash" > > # build initrd only to boot current hardware > hostonly="yes" > hostonly_cmdline="yes" > > I don't use lvm and sw-raid anymore, you might need: > > add_dracutmodules+="lvm bash mdraid" > > or so. > > After playing around some more hours with initram's i've finally found out what my problem was. It is easier than I though :D Basically my changes in my grub config were already correct, however I completely forgot, that, since I wrote my own init script, arg's like "root" and "init" simply weren't used by my script... If you look at my script, I only check the cmdline for "lvm", so setting "init" or "root" haven't any effect at all :D That means, after modifying my init script, using "/usr/lib/systemd/systemd" as init, systemd booted up. It's still not perfect - it looks like it can't mount other lvm partition's and thus only boot's into maintains mode - but it boot's :) Regarding dracut: Even though I got it to work, it also just bootet openrc and not systemd. Don't know why and I didn't digged further after it worked with my own script. Regarding LVM: As mentioned systemd can't mount my lvm partitions from fstab. Those lvm partitions should be mounted by UUID, but it seems like systemd can't find them, even though there are available afterwards (under /dev/vg0/...). If I comment them out in /etc/fstab (they are not important) systemd boots just fine. I've also set "use_lvmetad = 1" in /etc/lvm/lvm.conf as mentioned at the systemd wiki. Any clue why that doesn't work? -- greetings Michael Mair-Keimberger [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-14 18:43 ` Michael Mair-Keimberger @ 2014-11-16 1:21 ` wraeth 2014-11-17 20:39 ` Michael Mair-Keimberger 0 siblings, 1 reply; 16+ messages in thread From: wraeth @ 2014-11-16 1:21 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 2736 bytes --] On Fri, Nov 14, 2014 at 07:43:18PM +0100, Michael Mair-Keimberger wrote: > Basically my changes in my grub config were already correct, however I > completely forgot, that, since I wrote my own init script, arg's like > "root" and "init" simply weren't used by my script... > If you look at my script, I only check the cmdline for "lvm", so > setting "init" or "root" haven't any effect at all :D Glad you got this part of it sorted! I know how both relieving and frustrating it can be to find such a simple thing as the solution - it took me two weeks to realise I was calling 'mpc' and not 'mpd' in my startup script, explaining why MPD was never running... :-/ > Regarding dracut: Even though I got it to work, it also just bootet > openrc and not systemd. Don't know why and I didn't digged further after > it worked with my own script. You could try inspecting dmesg to try and determine why it isn't loading your chosen init. It could be something as simple as a typo, or if the filesystem (if you have /usr on a separate partition) isn't available at the time it's trying to launch init. > Regarding LVM: > As mentioned systemd can't mount my lvm partitions from fstab. Those lvm > partitions should be mounted by UUID, but it seems like systemd can't > find them, even though there are available afterwards (under > /dev/vg0/...). I've found dracut initrd's can be a little finicky with LVM volumes. With that in mind, here's the kernel cmdline for one of my systems wich uses LUKS->LVM->EXT4 for it's root partition. Note that it has explicit arguments for *all* LV's and not just root. BOOT_IMAGE=/vmlinuz-3.17.1-gentoo-r1 root=/dev/mapper/vg1-root ro rd.luks.uuid=luks-3f93b8aa-cf8b-4312-85d6-d45cffa59780 rd.lvm.lv=vg1/swap rd.lvm.lv=vg1/root resume=/dev/mapper/vg1-swap rootflags=rw,noatime,data=ordered rootfstype=ext4 quiet > If I comment them out in /etc/fstab (they are not important) systemd > boots just fine. I've also set "use_lvmetad = 1" in /etc/lvm/lvm.conf as > mentioned at the systemd wiki. This is a dracut-ism, in that if a static filesystem (as denoted by it's presence in /etc/fstab) is unmountable, it will assume there are problems and will drop to recovery. The idea of recovery is to identify your root partition with a symlink to the device node, after which you *should* be able to continue. ln -s /dev/<root_device> /dev/root See [1] for more. That being said, it may continue to drop to recovery - I've found the dracut recovery console to be a little temperamental with things like that... [1]: http://fedoraproject.org/wiki/How_to_debug_Dracut_problems Cheers; -- wraeth <wraeth@wraeth.id.au> GnuPG Key: B2D9F759 [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 213 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [gentoo-user] difficulties with lvm2+systemd+grub2 2014-11-16 1:21 ` wraeth @ 2014-11-17 20:39 ` Michael Mair-Keimberger 0 siblings, 0 replies; 16+ messages in thread From: Michael Mair-Keimberger @ 2014-11-17 20:39 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 4615 bytes --] On Sun, Nov 16, 2014 at 12:21:37PM +1100, wraeth wrote: > On Fri, Nov 14, 2014 at 07:43:18PM +0100, Michael Mair-Keimberger wrote: > > Basically my changes in my grub config were already correct, however I > > completely forgot, that, since I wrote my own init script, arg's like > > "root" and "init" simply weren't used by my script... > > If you look at my script, I only check the cmdline for "lvm", so > > setting "init" or "root" haven't any effect at all :D > > Glad you got this part of it sorted! I know how both relieving and > frustrating it can be to find such a simple thing as the solution - it > took me two weeks to realise I was calling 'mpc' and not 'mpd' in my > startup script, explaining why MPD was never running... :-/ > Thanks! Yeah, it can be really frustration, but it's worth the relieving feeling when you found the bug :) > > Regarding dracut: Even though I got it to work, it also just bootet > > openrc and not systemd. Don't know why and I didn't digged further after > > it worked with my own script. > > You could try inspecting dmesg to try and determine why it isn't loading > your chosen init. It could be something as simple as a typo, or if the > filesystem (if you have /usr on a separate partition) isn't available at > the time it's trying to launch init. Pretty sure! However, honestly I didn't look further into dracut for now (maybe another day - if I want to know how they work with lvm). BTW, with `dracut --print-cmdline` it prints you an example grub entry for your system, however it's doesn't set "init" and I think (otherwise I guess it would have work here) as long as you didn't already boot into systemd it wouldn't use it too... > > > Regarding LVM: > > As mentioned systemd can't mount my lvm partitions from fstab. Those lvm > > partitions should be mounted by UUID, but it seems like systemd can't > > find them, even though there are available afterwards (under > > /dev/vg0/...). > > I've found dracut initrd's can be a little finicky with LVM volumes. > With that in mind, here's the kernel cmdline for one of my systems wich > uses LUKS->LVM->EXT4 for it's root partition. Note that it has explicit > arguments for *all* LV's and not just root. > > BOOT_IMAGE=/vmlinuz-3.17.1-gentoo-r1 root=/dev/mapper/vg1-root ro > rd.luks.uuid=luks-3f93b8aa-cf8b-4312-85d6-d45cffa59780 > rd.lvm.lv=vg1/swap rd.lvm.lv=vg1/root resume=/dev/mapper/vg1-swap > rootflags=rw,noatime,data=ordered rootfstype=ext4 quiet > Thanks for sharing. From dracut's manual (man dracut.cmdline), rd.lvm.lv only activates given logical volumes, which should be the same like `vgchange -a y` (however i didn't look what exactly dracut does here). Since I'm already doing `vgchange -a y` in my init script, these logical volumes should be available for systemd. I've also checked for systemd's lvm service (lvm2-lvmetad.service) to make sure it's enabled and starts on boot, but it didn't changed anything. However, for now I just read-only mount these lv's directly via my init script and remount them write-able via /etc/local.d/*.start script's (glad to see systemd can make use of these scripts :) ) > > If I comment them out in /etc/fstab (they are not important) systemd > > boots just fine. I've also set "use_lvmetad = 1" in /etc/lvm/lvm.conf as > > mentioned at the systemd wiki. > > This is a dracut-ism, in that if a static filesystem (as denoted by it's > presence in /etc/fstab) is unmountable, it will assume there are > problems and will drop to recovery. The idea of recovery is to identify > your root partition with a symlink to the device node, after which you > *should* be able to continue. > > ln -s /dev/<root_device> /dev/root > > See [1] for more. That being said, it may continue to drop to recovery - > I've found the dracut recovery console to be a little temperamental with > things like that... > > [1]: http://fedoraproject.org/wiki/How_to_debug_Dracut_problems Hmm, not sure about that. I think you misunderstood me ;) I wasn't drop into dracut's (or in this case in my initramfs) rescue shell (if you meant that). I was drop into systemd maintaince mode, which means after it couldn't mount these other lv's it stops all services, keep / read only and ask for the root password. Done that I was still able to remount / and all other partitions... It seems like fstab's static filesystem are mandatory for systemd ;) > > Cheers; > -- > wraeth <wraeth@wraeth.id.au> > GnuPG Key: B2D9F759 -- greetings Michael Mair-Keimberger [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2014-11-17 20:39 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-11-11 20:56 [gentoo-user] difficulties with lvm2+systemd+grub2 Michael Mair-Keimberger 2014-11-11 21:44 ` Stefan G. Weichinger 2014-11-12 8:22 ` Michael Mair-Keimberger 2014-11-11 21:47 ` Jc García 2014-11-12 8:25 ` Michael Mair-Keimberger 2014-11-11 22:13 ` covici 2014-11-12 9:47 ` Michael Mair-Keimberger 2014-11-12 10:19 ` Stefan G. Weichinger 2014-11-12 11:44 ` covici 2014-11-12 1:03 ` wraeth 2014-11-12 9:42 ` Michael Mair-Keimberger 2014-11-12 10:07 ` Sam Jorna 2014-11-12 10:20 ` Stefan G. Weichinger 2014-11-14 18:43 ` Michael Mair-Keimberger 2014-11-16 1:21 ` wraeth 2014-11-17 20:39 ` Michael Mair-Keimberger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox