From e9e83635ee15102efa9c9633e7bb765a51616b07 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Tue, 17 Nov 2026 16:53:10 +0100 Subject: [PATCH] Name the created volumes in the grub defaults of an image install When the image has no /etc/default/grub, as images built by imgutil do not, installing it to disk on EL9 and EL10 wrote one with rd.lvm.lv=vg/root rd.lvm.lv=vg/swap, volumes that do not exist. A missing /etc/kernel/cmdline likewise got root=/dev/mapper/localstorage-root, which is wrong for an install without LVM or with a volume group named after the node. The boot loader entries were rewritten correctly, so the first boot worked, but grub2-mkconfig --update-bls-cmdline or a new kernel would take the wrong names from these files. Both defaults now name the root device and the logical volumes for root and swap that the install created. --- .../el9-diskless/profiles/default/scripts/image2disk.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py b/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py index 3698c5ba..28b460c3 100644 --- a/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py +++ b/confluent_osdeploy/el9-diskless/profiles/default/scripts/image2disk.py @@ -278,6 +278,11 @@ def fixup(rootdir, vols): else: newcfgparts.append(cfgpart) loadentout.write(' '.join(newcfgparts) + '\n') + # the logical volumes this install created, for the defaults below + lvmargs = '' + for lvdev in (newrootdev, newswapdev): + if lvdev and lvdev.startswith('/dev/{}/'.format(vgname)): + lvmargs += ' rd.lvm.lv={}'.format(lvdev[len('/dev/'):]) if os.path.exists(grubsyscfg): with open(grubsyscfg) as defgrubin: defgrub = defgrubin.read().split('\n') @@ -289,13 +294,13 @@ def fixup(rootdir, vols): 'GRUB_DISABLE_SUBMENU=true', 'GRUB_TERMINAL=""', 'GRUB_SERIAL_COMMAND=""', - 'GRUB_CMDLINE_LINUX="{} crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M rd.lvm.lv=vg/root rd.lvm.lv=vg/swap"'.format(currcmdlinestr), + 'GRUB_CMDLINE_LINUX="{} crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M{}"'.format(currcmdlinestr, lvmargs), 'GRUB_DISABLE_RECOVERY="true"', 'GRUB_ENABLE_BLSCFG=true', ] if not os.path.exists(os.path.join(rootdir, "etc/kernel/cmdline")): with open(os.path.join(rootdir, "etc/kernel/cmdline"), "w") as cmdlineout: - cmdlineout.write("{} root=/dev/mapper/localstorage-root rd.lvm.lv=localstorage/root".format(currcmdlinestr)) + cmdlineout.write("{} root={}{}".format(currcmdlinestr, newrootdev, lvmargs)) with open(grubsyscfg, 'w') as defgrubout: for gline in defgrub: gline = gline.split()