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 13:19:20
Message-Id: CAGfcS_k5wmA+n6E8XAWFp_nfDBxTn-quvo5uzsHcuYduBhosMQ@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 7:57 AM, gevisz <gevisz@×××××.com> wrote:
2 > 2016-09-07 12:36 GMT+03:00 Rich Freeman <rich0@g.o>:
3 >> On Tue, Sep 6, 2016 at 11:36 PM, Mike Gilbert <floppym@g.o> wrote:
4 >>>
5 >>> grub-mkconfig is not finding an initramfs, as evidenced by the lack of
6 >>> an "initrd" in in grub.cfg.
7 >>>
8 >>> If it is unable to find an initramfs, it will always output
9 >>> root=/dev/sdX instead of root=UUID=...
10 >>>
11 >>
12 >> For whatever reason the three subsequent replies to this list ignored
13 >> the actual explanation of the cause of the problems, which was this
14 >> (not uncommon on this list it seems).
15 >>
16 >> When root=UUID=... was added manually to the command line, then the
17 >> kernel refused to boot at all, because the kernel itself doesn't
18 >> understand that syntax.
19 >
20 > Yes, when the "root=UUID=***" has been added manually to /etc/default/grub
21 > in the wrong way, it appeared in the GRUB menu entry in the wrong way that
22 > stopped GRUB from booting in any case...
23
24 It doesn't matter how you add root=UUID=* to the kernel command line.
25 The kernel doesn't understand that syntax at all. Your initramfs
26 probably does.
27
28 When you don't use an initramfs (and you aren't using one, even if you
29 think you are), the kernel reads the value of root= and mounts it as
30 root. It doesn't understand the UUID syntax.
31
32 When you do use an initramfs then the kernel ignores the root=
33 setting, and the initramfs reads it and mounts root. Typically these
34 do understand the UUID syntax, but of course that depends on what
35 initramfs you're using.
36
37 >
38 >> So, the next question becomes, how are you generating an initramfs,
39 >> and how is it named? Pasting the output of "ls /boot" might be
40 >> helpful here.
41 >
42 > I generate initramfs by
43 > # genkernel --install initramfs
44 > and the rename it to match the name of the kernel, eg,
45 > initramfs-4.4.6-gentoo
46 > vmlinuz-4.4.6-gentoo
47
48 And if you read /etc/grub.d/10_linux you'll see that the script
49 doesn't look for an initramfs with the filename initramfs-<version>.
50
51 It will accept initramfs-<version>.img or initramfs-genkernel-<version>
52
53 It accepts 11 other variations of the filename, but not the one you picked.
54
55 So, grub-mkconfig doesn't think you have an initramfs, so it generated
56 a configuration file which:
57 1. Doesn't load an initramfs (so any attempt to stick a root=UUID=*
58 option in there will fail).
59 2. Just references the device name for root that it finds, since that
60 is the best it can do without an initramfs.
61
62 >
63 > But I think that this is unrelevant to the problem because of the following
64 > explanation I have just posted. (If I am wrong here, please, let me know
65 > and I will post all the conf files you will ask.)
66
67 No need, your filenames likely solved the problem. Just tack a .img
68 on the end of that initramfs and you should be good after running
69 grub-mkconfig again.
70
71 >
72 > When I connected a new SATA disk to the SATA controller, the order of
73 > hard disks during the boot time changed because the new disk "jumpt
74 > in front" of the boot drive. As the result, the GRUB could not find the
75 > boot partition by its UUID on the "wrong" non-boot drive and gave up,
76 > without even trying to look for the boot partition by its UUID on other
77 > hard drives!
78
79 Grub doesn't look for boot partitions at all. Grub just reads the
80 configuration file and loads the kernel (and optionally initramfs)
81 that it finds in grub.cfg. In your case the grub.cfg didn't list an
82 initramfs, so it didn't load one.
83
84 The initramfs generated by genkernel will look for a drive by UUID,
85 and as long as the device exists it will probably find it. Obviously
86 if you're missing a kernel module needed to access the drive that
87 would stop it. However, it doesn't care what order the devices are
88 numbered in.
89
90 >
91 > So, the question remains: why not to desing the GRUB in such a way
92 > that it could look for the boot partition by its UUID on any available
93 > hard drives?
94 >
95
96 It already does this. It just doesn't do it when it doesn't think
97 you're using an initramfs, because if it did it would make your system
98 unbootable, since the kernel doesn't know anything about UUIDs.
99
100 --
101 Rich

Replies

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