-# Backup old device.map
-mv ${MOUNTPOINT}/boot/grub/device.map ${MOUNTPOINT}/boot/grub/device.map.orig
-
-# Install grub
-for i in $LOOPB $LOOPA; do
- # Create new device map
- echo "(hd0) $i" > ${MOUNTPOINT}/boot/grub/device.map
-
- # Fix grub
- #XXX: e2fs_stage1_5 is 20 sectors embedded, but it fail with gpt
- #XXX: we use install command directly instead of setup (hd0) because it fail with loop
- cat << EOF | chroot ${MOUNTPOINT} grub --device-map=/boot/grub/device.map
-root (hd0,0)
-install --stage2=/boot/grub/stage2 /grub/stage1 (hd0) /grub/stage2 p /grub/menu.lst
-EOF
-done
-
-# Restore old device.map
-mv -f ${MOUNTPOINT}/boot/grub/device.map.orig ${MOUNTPOINT}/boot/grub/device.map
-
-# Bind mount /proc
-mount --bind /proc ${MOUNTPOINT}/proc
-
-# Bind mount /sys
-mount --bind /sys ${MOUNTPOINT}/sys
-