# Switch to boot by LABEL with grub2 in Rocky 9

**URL:** <https://forums.rockylinux.org/t/switch-to-boot-by-label-with-grub2-in-rocky-9/15269>\
**Category:** Rocky Linux Help & Support\
**Tags:** rocky-linux-9\
**Created:** [July 30, 2024, 10:55am UTC](https://forums.rockylinux.org/t/switch-to-boot-by-label-with-grub2-in-rocky-9/15269 "2024-07-30T10:55:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![heiko.wuest](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/heiko.wuest/32/4599_2.png) [@heiko.wuest](https://forums.rockylinux.org/u/heiko.wuest)\
**Post date:** [July 30, 2024, 10:55am UTC](https://forums.rockylinux.org/t/switch-to-boot-by-label-with-grub2-in-rocky-9/15269/1 "2024-07-30T10:55:50Z")

</div>

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:

```auto
# 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"

```

```auto
# 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”

---

<div class="post-metadata">

**Author:** ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)\
**Post date:** [July 30, 2024, 11:30am UTC](https://forums.rockylinux.org/t/switch-to-boot-by-label-with-grub2-in-rocky-9/15269/2 "2024-07-30T11:30:20Z")

</div>

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:

```auto
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).

---

<div class="post-metadata">

**Author:** ![heiko.wuest](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/heiko.wuest/32/4599_2.png) [@heiko.wuest](https://forums.rockylinux.org/u/heiko.wuest)\
**Post date:** [July 30, 2024, 12:41pm UTC](https://forums.rockylinux.org/t/switch-to-boot-by-label-with-grub2-in-rocky-9/15269/3 "2024-07-30T12:41:47Z")

</div>

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](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:

```auto
# 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)

```auto
# 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

---

<div class="post-metadata">

**Author:** ![jlehtone](https://avatars.discourse-cdn.com/v4/letter/j/e9a140/32.png) [@jlehtone](https://forums.rockylinux.org/u/jlehtone)\
**Post date:** [July 30, 2024, 1:09pm UTC](https://forums.rockylinux.org/t/switch-to-boot-by-label-with-grub2-in-rocky-9/15269/4 "2024-07-30T13:09:29Z")

</div>

> [@heiko.wuest](#):
>
> 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.)

---

<div class="post-metadata">

**Author:** ![heiko.wuest](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.rockylinux.org/heiko.wuest/32/4599_2.png) [@heiko.wuest](https://forums.rockylinux.org/u/heiko.wuest)\
**Post date:** [July 31, 2024, 7:32am UTC](https://forums.rockylinux.org/t/switch-to-boot-by-label-with-grub2-in-rocky-9/15269/5 "2024-07-31T07:32:45Z")

</div>

![Screenshot 2024-07-31 09.25.34](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/2X/b/b66e7e59995368ee0eee3abc373b0b502ed07154.png)

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/rockylinux/original/1X/91b7219eec10e30013422e4df76c1d898711a5d5.svg) [@system](https://forums.rockylinux.org/u/system)\
**Post date:** [September 29, 2024, 7:32am UTC](https://forums.rockylinux.org/t/switch-to-boot-by-label-with-grub2-in-rocky-9/15269/6 "2024-09-29T07:32:48Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
