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