97 lines
3.7 KiB
Diff
97 lines
3.7 KiB
Diff
|
From: Michael Chang <mchang@suse.com>
|
||
|
Subject: provide overridable root by subvol
|
||
|
|
||
|
References: fate#316522, fate#316232
|
||
|
Patch-Mainline: no
|
||
|
|
||
|
This patch provides a environment variable $subvol that can be used
|
||
|
to override path relative to absolute root by specific $subvol.
|
||
|
|
||
|
Signed-off-by: Michael Chang <mchang@suse.com>
|
||
|
|
||
|
Index: grub-2.02~beta2/util/grub.d/10_linux.in
|
||
|
===================================================================
|
||
|
--- grub-2.02~beta2.orig/util/grub.d/10_linux.in
|
||
|
+++ grub-2.02~beta2/util/grub.d/10_linux.in
|
||
|
@@ -55,7 +55,9 @@ case x"$GRUB_FS" in
|
||
|
xbtrfs)
|
||
|
rootsubvol="`make_system_path_relative_to_its_root /`"
|
||
|
rootsubvol="${rootsubvol#/}"
|
||
|
- if [ "x${rootsubvol}" != x ]; then
|
||
|
+ if [ "x$overridable_root_by_subvol" = "xtrue" ]; then
|
||
|
+ GRUB_CMDLINE_LINUX="\${rootflags} ${GRUB_CMDLINE_LINUX}"
|
||
|
+ elif [ "x${rootsubvol}" != x ]; then
|
||
|
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
|
||
|
fi;;
|
||
|
xzfs)
|
||
|
@@ -126,17 +128,43 @@ linux_entry ()
|
||
|
fi
|
||
|
printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
|
||
|
fi
|
||
|
+
|
||
|
+ if [ "x$overridable_root_by_subvol" = "xtrue" -a "x$GRUB_FS" = "xbtrfs" ]; then
|
||
|
+ sed "s/^/$submenu_indentation/" << EOF
|
||
|
+ if [ "x\$subvol" = "x" ]; then
|
||
|
+ bootdir="${rel_dirname}"
|
||
|
+ rootdir="${rootsubvol}"
|
||
|
+ else
|
||
|
+ bootdir="\${subvol}${dirname}"
|
||
|
+ rootdir="\${subvol}"
|
||
|
+ fi
|
||
|
+ if [ "x\${rootdir}" != "x" ]; then
|
||
|
+ rootflags="rootflags=subvol=\${rootdir}"
|
||
|
+ else
|
||
|
+ rootflags=""
|
||
|
+ fi
|
||
|
+EOF
|
||
|
+ fi
|
||
|
+
|
||
|
message="$(gettext_printf "Loading Linux %s ..." ${version})"
|
||
|
if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
|
||
|
sed "s/^/$submenu_indentation/" << EOF
|
||
|
echo '$message'
|
||
|
- linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
|
||
|
EOF
|
||
|
+ if [ "x$overridable_root_by_subvol" = "xtrue" -a "x$GRUB_FS" = "xbtrfs" ]; then
|
||
|
+ echo " linuxefi \${bootdir}/${basename} root=${linux_root_device_thisversion} ro ${args}" | sed "s/^/$submenu_indentation/"
|
||
|
+ else
|
||
|
+ echo " linuxefi ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}" | sed "s/^/$submenu_indentation/"
|
||
|
+ fi
|
||
|
else
|
||
|
sed "s/^/$submenu_indentation/" << EOF
|
||
|
echo '$(echo "$message" | grub_quote)'
|
||
|
- linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ${args}
|
||
|
EOF
|
||
|
+ if [ "x$overridable_root_by_subvol" = "xtrue" -a "x$GRUB_FS" = "xbtrfs" ]; then
|
||
|
+ echo " linux \${bootdir}/${basename} root=${linux_root_device_thisversion} ${args}" | sed "s/^/$submenu_indentation/"
|
||
|
+ else
|
||
|
+ echo " linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ${args}" | sed "s/^/$submenu_indentation/"
|
||
|
+ fi
|
||
|
fi
|
||
|
if test -n "${initrd}" ; then
|
||
|
# TRANSLATORS: ramdisk isn't identifier. Should be translated.
|
||
|
@@ -144,13 +172,21 @@ EOF
|
||
|
if [ -d /sys/firmware/efi ] && [ "x${GRUB_USE_LINUXEFI}" = "xtrue" ]; then
|
||
|
sed "s/^/$submenu_indentation/" << EOF
|
||
|
echo '$message'
|
||
|
- initrdefi ${rel_dirname}/${initrd}
|
||
|
EOF
|
||
|
+ if [ "x$overridable_root_by_subvol" = "xtrue" -a "x$GRUB_FS" = "xbtrfs" ]; then
|
||
|
+ echo " initrdefi \${bootdir}/${initrd}" | sed "s/^/$submenu_indentation/"
|
||
|
+ else
|
||
|
+ echo " initrdefi ${rel_dirname}/${initrd}" | sed "s/^/$submenu_indentation/"
|
||
|
+ fi
|
||
|
else
|
||
|
sed "s/^/$submenu_indentation/" << EOF
|
||
|
echo '$(echo "$message" | grub_quote)'
|
||
|
- initrd ${rel_dirname}/${initrd}
|
||
|
EOF
|
||
|
+ if [ "x$overridable_root_by_subvol" = "xtrue" -a "x$GRUB_FS" = "xbtrfs" ]; then
|
||
|
+ echo " initrd \${bootdir}/${initrd}" | sed "s/^/$submenu_indentation/"
|
||
|
+ else
|
||
|
+ echo " initrd ${rel_dirname}/${initrd}" | sed "s/^/$submenu_indentation/"
|
||
|
+ fi
|
||
|
fi
|
||
|
fi
|
||
|
sed "s/^/$submenu_indentation/" << EOF
|