From c92e94e88fb89eefe6806a278a5b4c43f5ab08d4 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 27 Aug 2012 20:20:55 +0200 Subject: [PATCH] dpkg-divert grub-probe binary to avoid problems in OpenVZ environments It's a hard to debug problem as it doesn't seem to be reproducible in every OpenVZ environment and on the other hand makes the system unusable as soon as the bug is triggered. :( On the command line/in the logs you'll notice something like that before the system is becoming unuseable: | Setting up grub-common (1.99-22.1) ... | Setting up grub2-common (1.99-22.1) ... | Setting up grub-pc-bin (1.99-22.1) ... | Setting up grub-pc (1.99-22.1) ... | | Creating config file /etc/default/grub with new version | grub-probe: error: cannot find a device for / (is /dev mounted?). | grub-probe: error: cannot find a device for /boot (is /dev mounted?). | grub-probe: error: cannot find a device for /boot/grub (is /dev mounted?). To avoid grub-probe being executed during software installation let's dpkg-divert the binary during the FAI dirinstall process through the existing hook script instsoft.GRMLBASE. Then revert the dpkg-divert via scripts/GRMLBASE/98-clean-chroot before actually building the ISO again. While at it also divert update-grub in the same code path as well. --- etc/grml/fai/config/hooks/instsoft.GRMLBASE | 22 ++++++++++++++++++++++ .../fai/config/scripts/GRMLBASE/98-clean-chroot | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/etc/grml/fai/config/hooks/instsoft.GRMLBASE b/etc/grml/fai/config/hooks/instsoft.GRMLBASE index ea1cfd0..65da202 100755 --- a/etc/grml/fai/config/hooks/instsoft.GRMLBASE +++ b/etc/grml/fai/config/hooks/instsoft.GRMLBASE @@ -48,6 +48,13 @@ EOF $ROOTCMD ln -s /bin/true /usr/sbin/update-grub fi + # work around a bug which causes openvz to freeze when grub-probe is invoked + if ! $ROOTCMD dpkg-divert --list | grep -q '/usr/sbin/grub-probe' ; then + echo "Diverting grub-probe executable" + $ROOTCMD dpkg-divert --rename --add /usr/sbin/grub-probe + $ROOTCMD ln -s /bin/true /usr/sbin/grub-probe + fi + # newer aptitude versions won't remove essential packages using # 'aptitude -f -y install file-rc' anymore, therefore force it: $ROOTCMD aptitude -o Aptitude::ProblemResolver::Keep-All-Tier=60000 -f -y install file-rc @@ -83,6 +90,21 @@ fi # no softupdate but fresh installation echo "Action $FAI_ACTION of FAI (hooks/instsoft.GRMLBASE) via grml-live running" +# work around /etc/kernel/postinst.d/zz-update-grub failing +# inside openvz environment, see #597084 +if ! $ROOTCMD dpkg-divert --list | grep -q '/usr/sbin/update-grub' ; then + echo "Diverting update-grub executable" + $ROOTCMD dpkg-divert --rename --add /usr/sbin/update-grub + $ROOTCMD ln -s /bin/true /usr/sbin/update-grub +fi + +# work around a bug which causes openvz to freeze when grub-probe is invoked +if ! $ROOTCMD dpkg-divert --list | grep -q '/usr/sbin/grub-probe' ; then + echo "Diverting grub-probe executable" + $ROOTCMD dpkg-divert --rename --add /usr/sbin/grub-probe + $ROOTCMD ln -s /bin/true /usr/sbin/grub-probe +fi + # make sure we have file-rc available before package_config/GRML* is being executed {{{ # the apt-get update might return an error if there's for example # a hashsum mismatch on Debian mirror sources, we might want to continue diff --git a/etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot b/etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot index 1a736ee..19464a2 100755 --- a/etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot +++ b/etc/grml/fai/config/scripts/GRMLBASE/98-clean-chroot @@ -35,6 +35,14 @@ if $ROOTCMD dpkg-divert --list | grep -q '/usr/sbin/update-grub' ; then $ROOTCMD dpkg-divert --rename --remove /usr/sbin/update-grub fi +# revert dpkg-divert of hooks/instsoft.GRMLBASE, which is +# used to work around a grub-probe<->openvz bug +if $ROOTCMD dpkg-divert --list | grep -q '/usr/sbin/grub-probe' ; then + echo "Undoing dpkg-divert of grub-probe executable" + $ROOTCMD rm -f /usr/sbin/grub-probe + $ROOTCMD dpkg-divert --rename --remove /usr/sbin/grub-probe +fi + # revert udev workaround of hooks/updatebase.GRMLBASE if grep -q 'updatebase.GRMLBASE' ${target}/etc/udev/kernel-upgrade 2>/dev/null ; then echo "Removing /etc/udev/kernel-upgrade created by updatebase.GRMLBASE" -- 2.1.4