Gentoo Archives: gentoo-user

From: Helmut Jarausch <jarausch@××××××.be>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] booting - I don't anystand how the (Linux) world works anymore
Date: Sat, 25 Jun 2016 20:24:04
Message-Id: 5YOYDGsZXFMwosPs9kiHVs@GffBcGezuaw3qnAFKkzCs
In Reply to: Re: [gentoo-user] booting - I don't anystand how the (Linux) world works anymore by Rich Freeman
1 Thanks Rich for the explanation.
2
3 Yes, I don't use an initramfs as it's not necessary in my simple case.
4
5 Fortunately, Jeremy's hint to use root=PARTUUID=.... works just fine
6 (if one knows about it)
7
8 Helmut
9
10
11 On 06/25/2016 09:46:21 PM, Rich Freeman wrote:
12 > On Sat, Jun 25, 2016 at 2:33 PM, Helmut Jarausch <jarausch@××××××.be>
13 > wrote:
14 > >
15 > > I don't understand the 'root=' option on the boot line like
16 > > kernel /boot/vmlinuz-4.7.0-rc4 root=/dev/sda1
17 > >
18 >
19 > It is pretty simple. If you're not using an initramfs, the kernel
20 > attempts to find the device you list and mount it as /, and then it
21 > runs whatever you pass in init=, or the canned list of init locations
22 > it has stored inside if you don't pass that. If you're using an
23 > initramfs, the kernel mounts it as / and runs its init, passing the
24 > root= parameter over to it.
25 >
26 > >
27 > > Having booted by SystemRescueCD from the cdrom device, my root
28 > device is
29 > > labelled /dev/sda1
30 > > BUT trying to use that on the kernel boot line fails (the kernel
31 > cannot
32 > > find the root file system)
33 > >
34 > > By trial and error I've found that I have to use root=/dev/sdb1
35 > >
36 > > but if I plug in an external drive (via USB) this doesn't work any
37 > more.
38 >
39 > As you've no doubt figured out, the issue is that these device names
40 > are assigned dynamically, and if your configuration changes (which I
41 > suppose might even include changing the boot device depending on your
42 > firmware), then these names can change. The kernel's logic is pretty
43 > basic and prone to these kinds of failures.
44 >
45 > >
46 > > So, I came up with root=UUID=uuid_number of the root file system.
47 > >
48 > > But to my surprise I now got a kernel panic
49 > > syncing: VFS: unable to mount root fs on unknown block(0,0)
50 > >
51 > > So, please tell me what I'm missing?
52 >
53 > The linux kernel doesn't have any concept of device UUIDs. It can
54 > only accept valid device names.
55 >
56 > The bit you're missing is that the kernel only interprets the root=
57 > parameter if you're not using an initramfs. If you're using an
58 > initramfs then the kernel just lets the initramfs mount root. The
59 > initramfs is basically a mini linux distro that can do just about
60 > anything it wants, and most have a way to handle devices identified by
61 > UUID.
62 >
63 > I'd suggest using dracut, which seems to be the most robust initramfs
64 > out there. To use it (or any other initramfs) there are basically a
65 > few steps:
66 >
67 > 1. Create an initramfs image in /boot (the syntax varies by tool).
68 > 2. Configure your bootloader to load the initramfs (the syntax varies
69 > by bootloader)
70 > 3. Pass an appropriate root= line to the kernel (the syntax varies by
71 > initramfs implementation, but most handle the syntax you gave, as well
72 > as the various udev paths that are based on UUIDs and labels and
73 > such).
74 >
75 > For dracut #1 is:
76 > dracut "" version (ie dracut "" 4.7.0-rc4)
77 >
78 > For grub1 #2 find the kernel line in your grub config file, and add a
79 > line:
80 > initrd <filename> (ie initrd initramfs-4.7.0-rc4.img)
81 >
82 > Use the same path in that as your kernel, so if your kernel has some
83 > kind of preceding directory path use the same for the initramfs.
84 >
85 > While you can often get away without using an initramfs, in general
86 > they tend to make the boot process more robust and they don't really
87 > have any impact on the system once it is running. They're loaded into
88 > a ramfs, and they typically delete themselves out of ram right before
89 > execing the real init. They just give you a LOT more options while
90 > booting (especially with dracut ; you'd probably be able to mount root
91 > off of iscsi over a vpn using it).
92 >
93 > --
94 > Rich
95 >
96 >
97 >