Skip to content

Commit 471dd7c

Browse files
committed
Enhance Bootloader with optional 'set prefix='
In distros like Almalinux 10, GRUB modules are installed in /usr/lib/grub in the rootfs. For GRUB to find them, a proper prefix has to be set, which we can identify using its UUID. This patch adds a new optional attribute to `Bootloader` object for this, which is a `dict` with two keys: - `uuid`: the UUID of the rootfs - `path`: the directory in the rootfs where modules will be searched for This is meant to be usable by host-installer in relevant contexts. Signed-off-by: Yann Dirson <yann.dirson@vates.tech>
1 parent f6b180f commit 471dd7c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

xcp/bootloader.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Bootloader(object):
8686
# pylint: disable=too-many-positional-arguments
8787
def __init__(self, src_fmt, src_file, menu = None, menu_order = None,
8888
default = None, timeout = None, serial = None,
89-
location = None, env_block = None):
89+
location = None, env_block = None, prefix = None):
9090

9191
if menu is None:
9292
menu = {}
@@ -104,6 +104,7 @@ def __init__(self, src_fmt, src_file, menu = None, menu_order = None,
104104
self.serial = serial
105105
self.location = location and location or 'mbr'
106106
self.env_block = env_block
107+
self.prefix = prefix
107108

108109
def append(self, label, entry):
109110
self.menu[label] = entry
@@ -297,6 +298,9 @@ def writeGrub2(self, dst_file = None):
297298
else:
298299
fh = open_textfile(cast(str, dst_file), "w")
299300

301+
if self.prefix:
302+
print(f"search --no-floppy --fs-uuid --set=rootdev {self.prefix['uuid']}", file=fh)
303+
print(f"set prefix=($rootdev){self.prefix['path']}", file=fh)
300304
if self.serial:
301305
print("serial --unit=%s --speed=%s" % (self.serial['port'],
302306
self.serial['baud']), file=fh)

0 commit comments

Comments
 (0)