Gentoo Archives: gentoo-user

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