On Sat, Jun 25, 2016 at 2:33 PM, Helmut Jarausch <jarau...@skynet.be> wrote:
>
> I don't understand  the   'root=' option on the boot line like
> kernel /boot/vmlinuz-4.7.0-rc4 root=/dev/sda1
>

It is pretty simple.  If you're not using an initramfs, the kernel
attempts to find the device you list and mount it as /, and then it
runs whatever you pass in init=, or the canned list of init locations
it has stored inside if you don't pass that.  If you're using an
initramfs, the kernel mounts it as / and runs its init, passing the
root= parameter over to it.

>
> Having booted by SystemRescueCD from the cdrom device, my root device is
> labelled  /dev/sda1
>  BUT trying to use that on the kernel boot line fails (the kernel cannot
> find the root file system)
>
> By trial and error I've found that I have to use   root=/dev/sdb1
>
> but if I plug in an external drive (via USB) this doesn't work any more.

As you've no doubt figured out, the issue is that these device names
are assigned dynamically, and if your configuration changes (which I
suppose might even include changing the boot device depending on your
firmware), then these names can change.  The kernel's logic is pretty
basic and prone to these kinds of failures.

>
> So, I came up with    root=UUID=uuid_number of the root file system.
>
> But to my surprise I now got  a kernel panic
> syncing: VFS: unable to mount root fs on unknown block(0,0)
>
> So, please tell me what I'm missing?

The linux kernel doesn't have any concept of device UUIDs.  It can
only accept valid device names.

The bit you're missing is that the kernel only interprets the root=
parameter if you're not using an initramfs.  If you're using an
initramfs then the kernel just lets the initramfs mount root.  The
initramfs is basically a mini linux distro that can do just about
anything it wants, and most have a way to handle devices identified by
UUID.

I'd suggest using dracut, which seems to be the most robust initramfs
out there.  To use it (or any other initramfs) there are basically a
few steps:

1.  Create an initramfs image in /boot (the syntax varies by tool).
2.  Configure your bootloader to load the initramfs (the syntax varies
by bootloader)
3.  Pass an appropriate root= line to the kernel (the syntax varies by
initramfs implementation, but most handle the syntax you gave, as well
as the various udev paths that are based on UUIDs and labels and
such).

For dracut #1 is:
dracut "" version (ie dracut "" 4.7.0-rc4)

For grub1 #2 find the kernel line in your grub config file, and add a line:
initrd <filename>  (ie initrd initramfs-4.7.0-rc4.img)

Use the same path in that as your kernel, so if your kernel has some
kind of preceding directory path use the same for the initramfs.

While you can often get away without using an initramfs, in general
they tend to make the boot process more robust and they don't really
have any impact on the system once it is running.  They're loaded into
a ramfs, and they typically delete themselves out of ram right before
execing the real init.  They just give you a LOT more options while
booting (especially with dracut ; you'd probably be able to mount root
off of iscsi over a vpn using it).

-- 
Rich

Reply via email to