Gentoo Archives: gentoo-user

From: "Canek Peláez Valdés" <caneko@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] problems debugging a systemd problem
Date: Thu, 28 May 2015 21:32:33
Message-Id: CADPrc83uf9im0gsKGxK0X3Yg300e5nLN-3785FotZnaExFOqKg@mail.gmail.com
In Reply to: Re: [gentoo-user] problems debugging a systemd problem by Rich Freeman
1 On Thu, May 28, 2015 at 1:36 PM, Rich Freeman <rich0@g.o> wrote:
2 >
3 > On Thu, May 28, 2015 at 2:11 PM, Canek Peláez Valdés <caneko@×××××.com>
4 wrote:
5 > >
6 > > Actually, it does work (see attached screenshot). I set my root= kernel
7 > > command line parameter wrong on purpose, and systemd (inside dracut)
8 dropped
9 > > me inside a rescue shell.
10 >
11 > Interesting. Perhaps it just enables shell access.
12 >
13 > There is a separate option that configures whether dracut drops to a
14 > shell at all, or if it just hangs on failure. The latter might be
15 > desirable for security purposes in some cases.
16 >
17 > Are you sure that you don't get a shell if you don't pass emergency on
18 > the command line, but still have an invalid root=?
19
20 I wasn't sure, I did a couple of tests more. I comment them below.
21
22 > >> Usually when somebody
23 > >> wants a rescue shell, they want it in their root filesystem, and not
24 > >> in their initramfs before it has pivoted. That is why dracut has
25 > >> options like rd.break.
26 > >
27 > > But that doesn't help you at all when the problem is exactly that you
28 cannot
29 > > mount your root filesystem. With the rescue shell of systemd (inside
30 > > dracut), you can analyze the problem, or perhaps even mount your root
31 > > filesystem and continue the boot process; the initramfs should have all
32 the
33 > > necessary tools to do that.
34 >
35 > rd.break DOES give you a shell before root is mounted, if you tell it to.
36 >
37 > rd.shell tells dracut to give you a shell if something fails
38 >
39 > rd.break forces a shell at the specified point, whether something fails
40 or not.
41 >
42 > The official docs do not list emergency as a valid dracut option.
43 > Obviously systemd uses it, but again the fact that you had to mangle
44 > your root= option sugests that systemd within dracut ignores it if it
45 > can mount your root.
46
47 No, if you set emergency or rescue, systemd will go to emergency.target and
48 rescue.target, respectively.
49
50 > >> If the problem were with systemd/services/etc in the actual root
51 > >> filesystem (once the actual distro has started booting), then putting
52 > >> emergency on the command line should get you a rescue shell.
53 > >
54 > > Again, what if the problem is before *that*?
55 >
56 > Then you tell dracut to drop to a shell. I wasn't aware that the
57 > emergency option actually made a difference, though I'm still not 100%
58 > sure that was what did it.
59
60 I'm now pretty sure it DOESN'T make a difference when the problem is
61 before you can mount root.
62
63 > >> The same generally applies to openrc - if the initramfs isn't mounting
64 > >> your root filesystem, then passing instructions to openrc won't do
65 > >> anything since in that case openrc isn't even running.
66 > >
67 > > But in this case, systemd *is* inside the initramfs:
68 > >
69 > > # ls usr/lib/systemd/
70 > > network systemd-cgroups-agent systemd-journald
71 systemd-shutdown
72 > > systemd-vconsole-setup
73 > > system systemd-fsck systemd-modules-load
74 systemd-sysctl
75 > > system-generators
76 > > systemd systemd-hibernate-resume systemd-reply-password systemd-udevd
77 > >
78 > > That's my initramfs. With dracut, systemd *is* the initramfs init
79 system.
80 >
81 > Sure, and that is how mine works as well. But, obviously systemd in
82 > dracut is configured to ignore that parameter when root= is valid,
83
84 No, it doesn't ignore it, even if root= is valid.
85
86 > otherwise you'd get a shell every time. I'd have to check the docs,
87 > but I suspect that the behavior is configurable, and systemd within
88 > the initramfs is configured differently. If nothing else they could
89 > just make the rescue target launch the default target/etc.
90
91 As I said, I did the following tests:
92
93 1. Adding "emergency" to the kernel command line, with a valid root=.
94 2. Adding "rescue" to the kernel command line, with a valid root=.
95 2. Leaving root= invalid without adding neither "emergency" nor "rescue".
96
97 If root= is valid, with emergency systemd drops you to a shell with your
98 root filesystem mounted read-only. With rescue, systemd drops you to a
99 shell with all your filesystems mounted read-write.
100
101 If root= is invalid, it doesn't matter if you use emergency, rescue, or
102 neither, *dracut* drops you to a shell, still inside the initramfs
103 obviously. It takes a while; I didn't took the time, but I think it was 3
104 minutes. Inside this shell, you can use systemd normally, and if you manage
105 to mount the root filesystem, I'm sure you could continue the normal boot
106 process. You'll have to pivot root manually, though.
107
108 Hope that makes it clear.
109
110 Regards.
111 --
112 Canek Peláez Valdés
113 Profesor de asignatura, Facultad de Ciencias
114 Universidad Nacional Autónoma de México

Replies

Subject Author
Re: [gentoo-user] problems debugging a systemd problem covici@××××××××××.com
Re: [gentoo-user] problems debugging a systemd problem Rich Freeman <rich0@g.o>