1 |
On Tue, Aug 6, 2019 at 7:41 PM Grant Taylor |
2 |
<gtaylor@×××××××××××××××××××××.net> wrote: |
3 |
> |
4 |
> On 8/6/19 10:28 AM, Rich Freeman wrote: |
5 |
> > An initramfs is just a userspace bootloader that runs on top of linux. |
6 |
> |
7 |
> I disagree. |
8 |
> |
9 |
> To me: |
10 |
> |
11 |
> · A boot loader is something that boots / executes a kernel with |
12 |
> various parameters. |
13 |
> · An initramfs / initrd (concept) is the micro installation that runs |
14 |
> under the kernel that was booted (by the boot loader). |
15 |
|
16 |
Bootloaders are just programs that run other programs, ultimately. We |
17 |
can argue all day about what kinds of programs count as each. But, |
18 |
there is no point arguing definitions. |
19 |
|
20 |
> The initramfs / initrd micro installation does the following: |
21 |
> |
22 |
> 1) fulfills prerequisites (e.g. loads requisite drivers, initializes |
23 |
> networking for and discovers storage, decrypts block devices) |
24 |
> 2) mounts root (and some other) file systems |
25 |
> 3) launches additional init scripts. |
26 |
|
27 |
So, an initramfs doesn't actually have to do ANY of those things, |
28 |
though typically it does. |
29 |
|
30 |
> None of those steps include booting / executing an alternate kernel. |
31 |
|
32 |
Nothing prevents an initramfs from booting an alternate kernel |
33 |
actually, though if it does it will need its own root filesystem |
34 |
initialized one way or another (which could be an initramfs). |
35 |
|
36 |
Linux bootstrapping linux is basically the whole premise behind coreboot. |
37 |
|
38 |
> |
39 |
> > and you don't need to have cruft all over your filesystem to do it. |
40 |
> |
41 |
> Actually yes you do need that cruft. |
42 |
|
43 |
Sure, but you don't need it ALL OVER YOUR FILESYSTEM. Some of the |
44 |
proposed solutions in this thread involved sticking stuff in /bin and |
45 |
so on. An initramfs is nicely bundled up in a single file. |
46 |
|
47 |
> If anything, having an initramfs / initrd means that you're going to |
48 |
> have an additional copy of said core system files in a slightly |
49 |
> different format (initramfs / initrd) that's not usable by the main system. |
50 |
|
51 |
Absolutely true, which means it won't interfere with the main system, |
52 |
as opposed to sticking it in /bin or somewhere where it might. |
53 |
|
54 |
> > and they make your bootstrapping process infinitely flexible. |
55 |
> |
56 |
> Nope. I don't agree. |
57 |
> |
58 |
> There have been many things that I've wanted to do in the past 20 years |
59 |
> that initramfs / initrd aren't flexible enough to do. |
60 |
|
61 |
Such as? |
62 |
|
63 |
It is a linux userspace. It can literally do anything. |
64 |
|
65 |
> But adding an init script that calls tools on the root file system is |
66 |
> infinitely more flexible. I'm not restricted to doing things that |
67 |
> dracut (et al.) know how to do. |
68 |
|
69 |
You don't need to use dracut (et al) to have an initramfs. |
70 |
|
71 |
In fact, you could create your super root filesystem that does all the |
72 |
fancy stuff you claim you can't do with an initramfs, then create a |
73 |
cpio archive of that root filesystem, and now you have an initramfs |
74 |
which does the job. |
75 |
|
76 |
> If I can boot the kernel, point it at a root disk, and launch an init |
77 |
> system, I can do anything I want with the system. |
78 |
|
79 |
Sure, but only if the kernel can find that disk without any userspace |
80 |
code. What if that disk is on the other side of an ssh tunnel? |
81 |
|
82 |
> Let me say it this way. If I can put together commands to do something, |
83 |
> I can get thee system to do it on boot. I don't have to wait for dracut |
84 |
> to be updated to support the next wiz-bang feature. |
85 |
|
86 |
If you know the commands to do something, why would you have to wait |
87 |
for somebody else to implement them? |
88 |
|
89 |
> |
90 |
> > If you want root to be a zip file hosted on a webserver somewhere |
91 |
> > that isn't a problem. If you want root to be a rar file on a |
92 |
> > gpg-encrypted attachment to a message stored on some IMAP server, |
93 |
> > you could do that too. To make all that work you can just script it |
94 |
> > in bash using regular userspace tools like curl or fetchmail, without |
95 |
> > any need to go mucking around with lower-level code. Then once your |
96 |
> > root filesystem is mounted all that bootstrapping code just deletes |
97 |
> > itself and the system operates as if it was never there (strictly |
98 |
> > speaking this isn't required but this is usually how it is done). |
99 |
> |
100 |
> You need /something/ to be your starting root file system. For most |
101 |
> servers / workstations / VMs / containers, that's a local directory |
102 |
> structure. |
103 |
|
104 |
Actually, for most of these the initramfs is the starting root |
105 |
filesystem (just about all linux server installs use one). Usually it |
106 |
just mounts a simple filesystem on a local disk as root and then |
107 |
pivots. |
108 |
|
109 |
However, an initramfs frees you up from the limitation that it be |
110 |
something that can be passed directly on the command line. |
111 |
|
112 |
> Sadly, I think people have thrust additional (IMHO) largely unnecessary |
113 |
> complexity into the init process just to be able to support more exotic |
114 |
> installations. Then, they have said "We want to be consistent in how we |
115 |
> boot, so we need to use this more complex thing everywhere." To which, |
116 |
> many greybeards have responded "I don't need nor want that on my simple |
117 |
> server." |
118 |
|
119 |
Initramfs is popular because it is way more flexible: |
120 |
|
121 |
1. You can build a fully modular kernel so that you can use the same |
122 |
kernel on every system but not be loading countless drivers for |
123 |
hardware most systems don't use, while still being certain of being |
124 |
able to boot any particular system. |
125 |
2. You have more access to labels/uuids/etc for finding the root |
126 |
filesystem so that when one of your hard drive fails the kernel |
127 |
doesn't just dumbly use the next one in sequence, assuming they're |
128 |
even always identified in the same order. |
129 |
3. You can use "exotic" installations like iscsi and so on, which |
130 |
seems pretty useful in an enterprise setting. |
131 |
|
132 |
> |
133 |
> If you /actually/ /need/ a micro installation to make your main |
134 |
> installation available, then go for it. But if you don't /actually/ |
135 |
> /need/ a micro installation, well Occam's Razor / Parsimony. |
136 |
|
137 |
Except then you're tailoring your bootloader to individual systems. |
138 |
|
139 |
Most sysadmins will prefer the Ubuntu/RHEL/etc approach where the same |
140 |
kernel/bootloader/etc works everywhere, vs tailoring their boot |
141 |
process to every individual host. |
142 |
|
143 |
> > They're a really elegant solution to the problem. |
144 |
> |
145 |
> I wouldn't use the words "elegant" or "solution". "kludge" comes to mind. |
146 |
|
147 |
What could be more elegant? It minimizes the complexity of the |
148 |
kernel, which is why Linus generally prohibits the kernel from having |
149 |
any more advanced root mounting logic, and why pretty much every Linux |
150 |
system out there uses one. |
151 |
|
152 |
-- |
153 |
Rich |