I'm trying to use partition labels (or UUIDs, that does not matter) to select root partition without use of an initrd/initramfs.
With initramfs, this is fairly easy:
root=/dev/disk/by-label/... in the kernel arguments does the job.
However, without initramfs the above is not possible: the
LABEL= notation is decoded by initramfs script, and
/dev/disk/by-label/... symlinks are created by udev running from the initramfs. Only the
root=/dev/sdXY notation is understood by the kernel itself.
However, GRUB supports shell-like scripting, and I think that it is somehow possible to write a GRUB 2 scriptlet that will generate
root=/dev/sdXY string from a device label or UUID.
Especially, the command
search --label <label> --set ROOTDEV will set variable
ROOTDEV with a string like
hd0,gpt5 which points to the partition with given label. If I understand correctly (please correct me if I'm wrong) the order of devices in GRUB and kernel is the same, so
/dev/sdb and so on.
So here is a question: is there a way, from inside the GRUB 2 script, to convert
/dev/sda5? Exactly the
sda part - the rest is easy with regexes.