2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-11-12 11:06:17 +00:00

Point boot entries at the kernel on the installed boot filesystem

image2disk rewrote root= in the boot loader entries but kept their
linux and initrd paths. Those come from where the image was built: in a
diskless image from imgutil they carry the scratch directory of the
server (grub2-mkrelpath sees its bind mount), and a /boot/ path does not
match the separate /boot filesystem image2disk creates for such images.
grub then fails with "you need to load the kernel". Make the paths
relative to the boot filesystem of the target.
This commit is contained in:
Markus Hilger
2026-11-01 15:02:43 +01:00
parent 89787671cf
commit 1d8d4f3077
@@ -205,6 +205,19 @@ def fixup(rootdir, vols):
with open(loadent, 'w') as loadentout:
for cfgline in currentry:
cfgparts = cfgline.split()
if cfgparts and cfgparts[0] in ('linux', 'initrd'):
# paths are relative to the boot filesystem of the target,
# not of the system that built the image
newcfgparts = [cfgparts[0]]
for cfgpart in cfgparts[1:]:
if cfgpart.startswith('/'):
if '/boot/' in cfgpart:
cfgpart = cfgpart[cfgpart.index('/boot/') + 5:]
if '/boot' not in devbymount:
cfgpart = '/boot' + cfgpart
newcfgparts.append(cfgpart)
loadentout.write(' '.join(newcfgparts) + '\n')
continue
if not cfgparts or cfgparts[0] != 'options':
loadentout.write(cfgline + '\n')
continue