2014-01-15 10:47:05 +00:00
|
|
|
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.
|
|
|
|
|
2014-01-17 12:38:35 +00:00
|
|
|
v1:
|
|
|
|
Introduce $boot_prefix for setting prefix on seeking other /boot
|
|
|
|
directory.
|
|
|
|
|
2014-03-31 19:51:24 +00:00
|
|
|
v2:
|
|
|
|
Refresh for s390x-emu.
|
|
|
|
|
2014-01-15 10:47:05 +00:00
|
|
|
Signed-off-by: Michael Chang <mchang@suse.com>
|
|
|
|
|
2014-03-31 19:51:24 +00:00
|
|
|
---
|
|
|
|
util/grub.d/10_linux.in | 57 ++++++++++++++++++++++++++++++++++++++++--------
|
|
|
|
1 file changed, 48 insertions(+), 9 deletions(-)
|
|
|
|
|
|
|
|
--- a/util/grub.d/10_linux.in
|
|
|
|
+++ b/util/grub.d/10_linux.in
|
2014-01-15 10:47:05 +00:00
|
|
|
@@ -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)
|
2014-03-31 19:51:24 +00:00
|
|
|
@@ -145,17 +147,43 @@ linux_entry ()
|
2014-01-15 10:47:05 +00:00
|
|
|
printf '%s\n' "${prepare_boot_cache}" | sed "s/^/$submenu_indentation/"
|
|
|
|
fi
|
2014-03-31 19:51:24 +00:00
|
|
|
fi
|
2014-01-15 10:47:05 +00:00
|
|
|
+
|
|
|
|
+ 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.
|
2014-03-31 19:51:24 +00:00
|
|
|
@@ -163,13 +191,21 @@ EOF
|
2014-01-15 10:47:05 +00:00
|
|
|
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
|
2014-03-31 19:51:24 +00:00
|
|
|
@@ -179,10 +215,13 @@ EOF
|
|
|
|
|
2014-01-17 12:38:35 +00:00
|
|
|
machine=`uname -m`
|
2014-03-31 19:51:24 +00:00
|
|
|
case "$machine" in
|
|
|
|
- i?86 | x86_64) klist="/boot/vmlinuz-* /vmlinuz-* /boot/kernel-*" ;;
|
|
|
|
- s390 | s390x) klist="/boot/image-* /boot/kernel-*" ;;
|
|
|
|
- *) klist="/boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* \
|
|
|
|
- /boot/kernel-*" ;;
|
|
|
|
+ i?86 | x86_64) klist="${boot_prefix}/boot/vmlinuz-* \
|
|
|
|
+ ${boot_prefix}/vmlinuz-* ${boot_prefix}/boot/kernel-*" ;;
|
|
|
|
+ s390 | s390x) klist="${boot_prefix}/boot/image-* \
|
|
|
|
+ ${boot_prefix}/boot/kernel-*" ;;
|
|
|
|
+ *) klist="${boot_prefix}/boot/vmlinuz-* \
|
|
|
|
+ ${boot_prefix}/boot/vmlinux-* ${boot_prefix}/vmlinuz-* \
|
|
|
|
+ ${boot_prefix}/vmlinux-* /boot/kernel-*" ;;
|
2014-01-17 12:38:35 +00:00
|
|
|
esac
|
2014-03-31 19:51:24 +00:00
|
|
|
list=`for i in $klist; do
|
|
|
|
if grub_file_is_not_garbage "$i" ; then
|