summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/templates/grub/grub_common.j25
-rw-r--r--data/templates/grub/grub_compat.j211
-rw-r--r--python/vyos/system/compat.py19
-rw-r--r--src/system/grub_update.py13
4 files changed, 30 insertions, 18 deletions
diff --git a/data/templates/grub/grub_common.j2 b/data/templates/grub/grub_common.j2
index 78df3f48c..278ffbf2c 100644
--- a/data/templates/grub/grub_common.j2
+++ b/data/templates/grub/grub_common.j2
@@ -18,5 +18,6 @@ function setup_serial {
setup_serial
-# find root device
-#search --no-floppy --fs-uuid --set=root ${root_uuid}
+{% if search_root %}
+{{ search_root }}
+{% endif %}
diff --git a/data/templates/grub/grub_compat.j2 b/data/templates/grub/grub_compat.j2
index 935172005..887d5d0bd 100644
--- a/data/templates/grub/grub_compat.j2
+++ b/data/templates/grub/grub_compat.j2
@@ -45,9 +45,14 @@ serial --unit=0 --speed=115200
{% endif %}
terminal_output --append serial
terminal_input serial console
-{% if efi %}
-insmod efi_gop
-insmod efi_uga
+{% for mod in modules %}
+insmod {{ mod }}
+{% endfor %}
+{% if root %}
+set root={{ root }}
+{% endif %}
+{% if search_root %}
+{{ search_root }}
{% endif %}
{% for v in versions %}
diff --git a/python/vyos/system/compat.py b/python/vyos/system/compat.py
index aa9b0b4b5..319c3dabf 100644
--- a/python/vyos/system/compat.py
+++ b/python/vyos/system/compat.py
@@ -86,6 +86,12 @@ def filter_unparsed(grub_path: str) -> str:
return filtered
+def get_search_root(unparsed: str) -> str:
+ unparsed_lines = unparsed.splitlines()
+ search_root = next((x for x in unparsed_lines if 'search' in x), '')
+ return search_root
+
+
def sanitize_boot_opts(boot_opts: str) -> str:
"""Sanitize boot options from console and init
@@ -269,18 +275,21 @@ def grub_cfg_fields(root_dir: str = '') -> dict:
fields = {'default': 0, 'timeout': 5}
# 'default' and 'timeout' from legacy grub.cfg
fields |= grub.vars_read(grub_cfg_main)
+
fields['tools_version'] = SYSTEM_CFG_VER
menu_entries = update_version_list(root_dir)
fields['versions'] = menu_entries
+
default = get_default(menu_entries, root_dir)
if default is not None:
fields['default'] = default
- p = Path('/sys/firmware/efi')
- if p.is_dir():
- fields['efi'] = True
- else:
- fields['efi'] = False
+ modules = grub.modules_read(grub_cfg_main)
+ fields['modules'] = modules
+
+ unparsed = filter_unparsed(grub_cfg_main).splitlines()
+ search_root = next((x for x in unparsed if 'search' in x), '')
+ fields['search_root'] = search_root
return fields
diff --git a/src/system/grub_update.py b/src/system/grub_update.py
index da1986e9d..366a85344 100644
--- a/src/system/grub_update.py
+++ b/src/system/grub_update.py
@@ -55,7 +55,10 @@ if __name__ == '__main__':
vyos_menuentries = compat.parse_menuentries(grub_cfg_main)
vyos_versions = compat.find_versions(vyos_menuentries)
unparsed_items = compat.filter_unparsed(grub_cfg_main)
-
+ # compatibilty for raid installs
+ search_root = compat.get_search_root(unparsed_items)
+ common_dict = {}
+ common_dict['search_root'] = search_root
# find default values
default_entry = vyos_menuentries[int(vars['default'])]
default_settings = {
@@ -66,11 +69,6 @@ if __name__ == '__main__':
}
vars.update(default_settings)
- # print(f'vars: {vars}')
- # print(f'modules: {modules}')
- # print(f'vyos_menuentries: {vyos_menuentries}')
- # print(f'unparsed_items: {unparsed_items}')
-
# create new files
grub_cfg_vars = f'{root_dir}/{grub.CFG_VYOS_VARS}'
grub_cfg_modules = f'{root_dir}/{grub.CFG_VYOS_MODULES}'
@@ -81,8 +79,7 @@ if __name__ == '__main__':
Path(image.GRUB_DIR_VYOS).mkdir(exist_ok=True)
grub.vars_write(grub_cfg_vars, vars)
grub.modules_write(grub_cfg_modules, modules)
- # Path(grub_cfg_platform).write_text(unparsed_items)
- grub.common_write()
+ grub.common_write(grub_common=common_dict)
render(grub_cfg_menu, grub.TMPL_GRUB_MENU, {})
render(grub_cfg_options, grub.TMPL_GRUB_OPTS, {})