Ensure that grub-pc/install_devices is pointing to the requested device
[grml-debootstrap.git] / grml-debootstrap
index be7bf63..322c931 100755 (executable)
@@ -892,7 +892,7 @@ fi
 CURRENT_ARCH="$(uname -m)"
 if [ "$CURRENT_ARCH" != "x86_64" ] ; then
    if [ "$ARCH" = "amd64" ] ; then
-      eerror "It is not possible to build amd64 on $CURRENT_ARCH." ; eend 1
+      eerror "It is not possible to build amd64 on $CURRENT_ARCH. Consider installing and booting the 'linux-image-amd64' kernel or using '--arch i386' instead." ; eend 1
       bailout 1
    fi
 fi
@@ -1102,8 +1102,7 @@ prepare_vm() {
   if [ -n "$VMFILE" ]; then
     qemu-img create -f raw "${TARGET}" "${VMSIZE}"
   fi
-  echo 4 66 | /usr/share/grml-debootstrap/bootgrub.mksh -A | dd of="$TARGET" conv=notrunc
-  dd if=/dev/zero bs=1 conv=notrunc count=64 seek=446 of="$TARGET"
+  parted -s "${TARGET}" 'mklabel msdos'
   if [ "$FIXED_DISK_IDENTIFIERS" = "yes" ] ; then
     einfo "Adjusting disk signature to a fixed (non-random) value"
     MBRTMPFILE=$(mktemp)
@@ -1113,6 +1112,7 @@ prepare_vm() {
     eend $?
   fi
   parted -s "${TARGET}" 'mkpart primary ext4 2M -1'
+  parted -s "${TARGET}" 'set 1 boot on'
 
   # if dm-mod isn't available then kpartx will fail with
   # "Is device-mapper driver missing from kernel? [...]"
@@ -1191,8 +1191,9 @@ if [[ -z "${GRUB}" ]] || ! dd if="${GRUB}" bs=512 count=1 2>/dev/null | cat -v |
       cp -a "${MNTPOINT}"/usr/lib/grub/i386-pc "${MNTPOINT}/boot/grub/"
       ;;
   esac
+  dd if="${MNTPOINT}/usr/lib/grub/i386-pc/boot.img" of="${ORIG_TARGET}" conv=notrunc bs=440 count=1
   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
+  dd if="${MNTPOINT}/tmp/core.img" of="${ORIG_TARGET}" conv=notrunc seek=1
   rm -f "${MNTPOINT}/tmp/core.img"
 fi