On Mon, Feb 13, 2017 at 5:53 AM, marco restelli <mreste...@gmail.com> wrote:
>
> Could you suggest any reference about how an initramfs can help making
> it easier to identify the correct root filesystem? Does this
> functionality overlap with what grub can do, or is something
> different?
>

The dracut references are fairly extensive, but they probably assume
that you already know about something like this.  Keep in mind that on
virtually all other distros end-users aren't expected to set up their
own kernels or initramfs so there isn't a lot of general documentation
out there.  And even within Gentoo a lot of people seem to avoid an
initramfs, so our own docs may not be as extensive as they could be.

The short version is that the kernel is very limited in what it can
take in the root= option on the command line, and grub and other
bootloaders don't do anything to ID the root filesystem other than
passing whatever root= parameter you specify (I'd be interested in any
info to the contrary).

The kernel itself can't handle UUIDs or filesystem labels.  It
actually can handle some situations like lvm on top of mdadm, but that
is about as complex as it gets as far as I'm aware, and even in that
situation there are some limitations.

An initramfs is typically implemented in a bunch of shell scripts
(though it is really a full userspace so in theory you can really have
it do anything).  That gives it a lot more flexibility.  Typically
they run udev which gives you all the /dev/disk/by-id symlinks and so
on.  They can also do things like fsck root before mounting it (though
mounting it read-only and having it fsck itself isn't a terrible
alternative, which is how things work without an initramfs).

Basically an initramfs should be viewed as an extended bootloader.
For more exotic setups they're essentially required (such as
network-based root filesystems).  The trend has also been to not add
new root-finding capabilities to the kernel as the initramfs is the
preferred way of doing things.  If lvm+mdadm were being built today,
I'm not sure they would make the kernel capable of directly mounting
them as root.

Anytime you see something like root=UUID=* that is being handled by an
initramfs.  And of course a UUID is more reliable than a device name,
since the latter can change if you add/remove a device, or maybe even
if your firmware is having a bad day.  Identifying devices by UUID
ensures the right one gets found, assuming it is available.  If you're
using something like mdadm/lvm there are alternatives to UUID, but the
point is the same, you're using a logical identifier that is based on
what is stored on the disks and not just what port it is connected to.

-- 
Rich

Reply via email to