From: Sebastian Pipping Date: Wed, 6 May 2015 16:56:46 +0000 (+0200) Subject: Install GRUB once, at most (second take, issue #78) X-Git-Tag: v0.70~7 X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=commitdiff_plain;h=45247578146cd1c92c73d29c1ce8cd727d3cb6b3;ds=sidebyside Install GRUB once, at most (second take, issue #78) --- diff --git a/grml-debootstrap b/grml-debootstrap index f218f7c..622a693 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -1093,12 +1093,15 @@ finalize_vm() { bailout 1 fi - einfo "Installing Grub as bootloader." mount -t proc none "${MNTPOINT}"/proc mount -t sysfs none "${MNTPOINT}"/sys mount --bind /dev "${MNTPOINT}"/dev mount --bind /dev/pts "${MNTPOINT}"/dev/pts +# Has chroot-script installed GRUB to MBR using grub-install (successfully), already? +# chroot-script skips installation for unset ${GRUB} +if [[ -z "${GRUB}" ]] || ! dd if="${GRUB}" bs=512 count=1 2>/dev/null | cat -v | fgrep -q GRUB; then + einfo "Installing Grub as bootloader." mkdir -p "${MNTPOINT}/boot/grub" if ! [ -d "${MNTPOINT}"/usr/lib/grub/i386-pc/ ] ; then eerror "Error: grub not installed inside Virtual Machine. Can not install bootloader." ; eend 1 @@ -1116,6 +1119,7 @@ finalize_vm() { chroot "${MNTPOINT}" grub-mkimage -O i386-pc -p "(hd0,msdos1)/boot/grub" -o /tmp/core.img biosdisk part_msdos ext2 dd if="${MNTPOINT}/tmp/core.img" of="${ORIG_TARGET}" conv=notrunc seek=4 rm -f "${MNTPOINT}/tmp/core.img" +fi einfo "Updating grub configuration file." if [ -n "$BOOT_APPEND" ] ; then