Gentoo Archives: gentoo-user

From: Rich Freeman <rich0@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Kernel does not boot after adding a new SATA drive
Date: Wed, 07 Sep 2016 18:46:19
Message-Id: CAGfcS_nL20Q06uieqE+QudZuiQ9Mku5HQ_iuCb6qVxQv12oWQQ@mail.gmail.com
In Reply to: Re: [gentoo-user] Kernel does not boot after adding a new SATA drive by gevisz
1 On Wed, Sep 7, 2016 at 2:25 PM, gevisz <gevisz@×××××.com> wrote:
2 >
3 > What you have just said implies that I had not had a problem
4 > booting the system after adding a new drive had I used initramfs
5 > correctly. Well, I do agree that, after loading the initramfs, the system
6 > may find the kernel to load with the help of initramfs that understands
7 > UUID. However, how the GRUB could find the initramfs in the first place,
8 > if it could not find the kerner allocated in the same directory as the
9 > initramfs itself?
10
11 grub-mkconfig simply searches for a configurable list of filename
12 specifications which your initramfs didn't match. Since /boot could
13 contain all sorts of files, with all sorts of naming conventions, it
14 obviously would be very difficult to accomodate any possible naming
15 convention. We apparently do have it set up to search the filenames
16 generated by the initramfs tools we actually use, so as long as you
17 don't go renaming them you're probably fine.
18
19 At boot time grub doesn't search for anything. It simply reads the
20 config file and does what it tells it.
21
22 >
23 > Moreover, in the GRUB menu entry provided above, the initramfs loads
24 > already after the kernel. So, using the initramfs should be irrelevant to
25 > the question of finding the kernel to load by GRUB.
26 >
27
28 Grub is loading the kernel in your case. The kernel just isn't
29 mounting the root filesystem since there is no initramfs to tell it
30 how to do that. Grub has nothing to do with mounting root at boot
31 time.
32
33 Grub also loads the initramfs before it ever executes the kernel. The
34 kernel doesn't know how to load an initramfs from disk. It expects it
35 to be in RAM when it runs.
36
37 The initramfs loaded by grub is just a cpio image that is copied into
38 RAM, and I believe the address gets passed as a kernel command line
39 argument (one you don't even see in grub, it appends it at runtime).
40 The kernel creates a ramfs, extracts the cpio image into the ramfs,
41 and executes init inside of it. At that point the kernel is
42 essentially done with booting the system, the initramfs can mount and
43 pivot to a new root, or the whole system could just run off of an
44 initramfs until it shuts down. This is why the kernel developers have
45 shunned kernel mounting logic/etc in favor of the initramfs; it moves
46 more of the logic into userspace where it is easier to
47 change/maintain/etc, and doesn't have to necessarily run with kernel
48 privs either. Heck, your initramfs could go out on the network, pull
49 in another kernel image and initramfs, and kexec that (which I think
50 is basically the design of coreboot which is a linux-based
51 bootloader).
52
53
54 --
55 Rich

Replies

Subject Author
Re: [gentoo-user] Kernel does not boot after adding a new SATA drive gevisz <gevisz@×××××.com>