if a (legacy) system is booted with proxmox-boot-tool, running
`grub-install` without being aware of the fact can render the system
unbootable (e.g. when letting the early stage point to an incompatible
zpool instead of the ESP).
To prevent this we add a dpkg-diversion [0], which simply checks if
`proxmox-boot-tool status` indicates that proxmox-boot is used and
errors out in that case, and runs the actual grub-install else.
Co-authored-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
install:
install -d ${SBINDIR}
install -m 0755 proxmox-boot-tool ${SBINDIR}/
+ install -m 0755 grub-install-wrapper ${SBINDIR}/grub-install
.PHONY: clean distclean
distclean:
--- /dev/null
+#! /bin/sh
+set -e
+
+. /usr/share/pve-kernel-helper/scripts/functions
+
+if proxmox-boot-tool status --quiet; then
+ warn "grub-install is disabled because this system is booted via proxmox-boot-tool, if you really need to run it, run /usr/sbin/grub-install.real"
+ exit 1
+else
+ grub-install.real "$@"
+fi
+
mv "$esp_mp/$PMX_LOADER_CONF.tmp" "$esp_mp/$PMX_LOADER_CONF"
else
echo "Installing grub i386-pc target.."
- grub-install \
+ grub-install.real \
--boot-directory $esp_mp \
--target i386-pc \
--no-floppy \
etc/kernel/postrm.d/*
etc/initramfs/post-update.d/proxmox-boot-sync
usr/sbin/proxmox-boot-tool
+usr/sbin/grub-install
usr/share/pve-kernel-helper/scripts/functions
--- /dev/null
+#! /bin/sh
+
+set -e
+
+case "$1" in
+ remove|abort-install|disappear)
+ dpkg-divert --package pve-kernel-helper --remove --rename \
+ --divert /usr/sbin/grub-install.real /usr/sbin/grub-install
+ ;;
+ abort-upgrade)
+ if [ -n "$2" ]; then
+ if dpkg --compare-versions "$2" lt 6.3-9; then
+ dpkg-divert --package pve-kernel-helper --remove --rename \
+ --divert /usr/sbin/grub-install.real /usr/sbin/grub-install
+ fi
+ fi
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
--- /dev/null
+#! /bin/sh
+
+set -e
+
+case "$1" in
+ install)
+ if [ -z "$2" ]; then
+ dpkg-divert --package pve-kernel-helper --add --rename \
+ --divert /usr/sbin/grub-install.real /usr/sbin/grub-install
+ fi
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0