i have a bunch of Rocky 9 vm’s. They are upgraded from centos8 and running with BIOS boot under vmware.
I would like to switch that grub2 boots by LABEL instead of disk name or uuid.
i changed:
# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU="true"
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="fsck.mode=force fsck.repair=yes"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG="true"
GRUB_DISABLE_LINUX_UUID="true"
GRUB_ENABLE_LINUX_LABEL="true"
# grubby --info ALL
index=0
kernel="/boot/vmlinuz-5.14.0-427.26.1.el9_4.x86_64"
args="ro fsck.mode=force fsck.repair=yes"
root="/dev/sda1"
initrd="/boot/initramfs-5.14.0-427.26.1.el9_4.x86_64.img $tuned_initrd"
title="Rocky Linux (5.14.0-427.26.1.el9_4.x86_64) 9.4 (Blue Onyx)"
id="1293acf886cb457d8177f086c1771800-5.14.0-427.26.1.el9_4.x86_64"
it allways defaults to the disk /dev/sda1 device.
is this the correct parameter?
GRUB_ENABLE_LINUX_LABEL=“true”
The /etc/default/grub is used by grub2-mkconfig (and scripts in /etc/grub.d/) to generate the grub.cfg (and some other files). I don’t see enable label in:
grep -Er "LABEL|GRUB_DISABLE|GRUB_ENABLE" /usr/sbin/grub2-mkconfig /etc/grub.d
The “some other files” is now significant – each regular GRUB entry is a file in /boot/loader/entries/ and you need grub2-mkconfig --update-bls-cmdline to recreate them.
When new kernel installs, it gets /boot/loader/entries/*.conf from grubby, which uses /etc/kernel/cmdline for some options. The latter file might be updated by grub2-mkconfig --update-bls-cmdline or grubby --update.
Since the “root=…” is copied from /etc/kernel/cmdline to every /boot/loader/entries/*.conf – not from /etc/default/grub – focus on it (or those GRUB…UUID… variables).
Thanks for your fast help,
GRUB_ENABLE_LINUX_LABEL=“true” doesn’t work. There seems to be a patch which never made it in the release:
https://lists.gnu.org/archive/html/grub-devel/2023-09/msg00099.html
so grub2-mkconfig --update-bls-cmdline seems to recreate /etc/kernel/cmdline
which creates the needed boot entries:
# grubby --info ALL
index=0
kernel="/boot/vmlinuz-5.14.0-427.26.1.el9_4.x86_64"
args="ro root=LABEL=ROOT fsck.mode=force fsck.repair=yes"
root="/dev/sda1"
initrd="/boot/initramfs-5.14.0-427.26.1.el9_4.x86_64.img $tuned_initrd"
title="Rocky Linux (5.14.0-427.26.1.el9_4.x86_64) 9.4 (Blue Onyx)"
id="1293acf886cb457d8177f086c1771800-5.14.0-427.26.1.el9_4.x86_64"
when i enable UUID: (GRUB_DISABLE_LINUX_UUID=false in /etc/default/grub)
# grubby --info ALL
index=0
kernel="/boot/vmlinuz-5.14.0-427.26.1.el9_4.x86_64"
args="ro root=LABEL=ROOT fsck.mode=force fsck.repair=yes"
root="UUID=1a565525-046b-489b-ad9b-8f0d673c8dfc"
so either the entries boot by disk path or by UUID never by label
Idea: edit the /etc/kernel/cmdline to contain label and do not run grub2-mkconfig after that.
(If grubby does the edit while changing ‘root=’ in entries, fine, else manually – for future kernels.)
that doesn’t work it allways adds root=/dev/sda1 or the UUID Version, with the /etc/kernel/cmdline hack i can create a second root= option only.
I guess there is no chance to achieve my target this way, either a patched 10_linux script or i need to stay with classic old /dev/sda1