2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-11-19 08:52:20 +00:00

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.
This commit is contained in:
Markus Hilger
2026-11-17 16:53:10 +01:00
parent 209d6ef2ed
commit e9e83635ee
@@ -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()