diff options
-rwxr-xr-x | kvmx-create | 54 | ||||
-rw-r--r-- | kvmxfile | 3 |
2 files changed, 43 insertions, 14 deletions
diff --git a/kvmx-create b/kvmx-create index dacab4a..7f20585 100755 --- a/kvmx-create +++ b/kvmx-create @@ -123,6 +123,7 @@ function kvmx_config { kvmx_user_config size 3G "Image size" kvmx_user_config format qcow2 "Image format: raw or qcow2" kvmx_user_config method custom "Bootstrap method: custom or vmdeboostrap" + kvmx_user_config bootloader grub "Bootloader: grub or extlinux" } # Load config file @@ -156,10 +157,15 @@ function kvmx_create_vmdebootstrap { formt="" fi + if [ "$booloader" == "grub" ]; then + boot_option="--grub" + else + boot_option="" + fi + # Run kvmx_sudo_run vmdebootstrap --verbose --image=$image --size=$size --distribution=$version \ - --mirror=$mirror --arch=$arch --hostname=$hostname.$domain \ - --grub $format + --mirror=$mirror --arch=$arch --hostname=$hostname.$domain $boot_option $format # Fix permissions kvmx_sudo_run chown -R `whoami`. `dirname $image` @@ -283,21 +289,41 @@ allow-hotplug ens3 iface ens3 inet dhcp EOF - # GRUB + # Mount auxiliary filesystems needed by the bootloader kvmx_sudo_run mount none -t proc $WORK/proc kvmx_sudo_run mount none -t sysfs $WORK/sys kvmx_sudo_run mount -o bind /dev/ $WORK/dev - $APT_INSTALL grub-pc -y - # GRUB install is not working for jessie and this was an attempt to fix it - # Consider fixing this or moving to extlinux. - # https://superuser.com/questions/130955/how-to-install-grub-into-an-img-file - # http://www.grulic.org.ar/~mdione/glob/posts/create-a-disk-image-with-a-booting-running-debian/ - # http://www.syslinux.org/wiki/index.php?title=EXTLINUX - # https://packages.debian.org/jessie/grub-firmware-qemu - #kvmx_sudo_run sed -i -e 's|^#GRUB_DISABLE_LINUX_UUID=true|GRUB_DISABLE_LINUX_UUID=true|' $WORK/etc/default/grub - #kvmx_sudo_run grub-install --boot-directory=$WORK/boot $image - kvmx_sudo_run chroot $WORK/ update-grub - kvmx_sudo_run chroot $WORK/ grub-install $device + + if [ "$bootloader" == "grub" ]; then + # Possible alternative: https://packages.debian.org/jessie/grub-firmware-qemu + $APT_INSTALL grub-pc + # GRUB install is not working for jessie and this was an attempt to fix it + #kvmx_sudo_run sed -i -e 's|^#GRUB_DISABLE_LINUX_UUID=true|GRUB_DISABLE_LINUX_UUID=true|' $WORK/etc/default/grub + kvmx_sudo_run chroot $WORK/ update-grub + kvmx_sudo_run chroot $WORK/ grub-install $device + # Alternative: install from the host directly into the image + # https://superuser.com/questions/130955/how-to-install-grub-into-an-img-file + #kvmx_sudo_run grub-install --boot-directory=$WORK/boot $image + elif [ "$bootloader" == "extlinux" ]; then + # http://www.grulic.org.ar/~mdione/glob/posts/create-a-disk-image-with-a-booting-running-debian/ + # http://www.syslinux.org/wiki/index.php?title=EXTLINUX + # http://www.syslinux.org/wiki/index.php?title=Mbr + $APT_INSTALL extlinux + kvmx_sudo_run chroot $WORK/ extlinux --install /boot + kvmx_sudo_run dd bs=440 count=1 conv=notrunc if=$WORK/usr/lib/EXTLINUX/gptmbr.bin of=$device + cat <<-EOF | $SUDO tee $WORK/boot/syslinux.cfg > /dev/null +default linux +timeout 1 + +label linux +say Booting linux... +linux /vmlinuz +append root=/dev/vda1 ro +initrd /initrd.img +EOF + fi + + # Umount auxiliary filesystems kvmx_sudo_run umount $WORK/proc kvmx_sudo_run umount $WORK/sys kvmx_sudo_run umount $WORK/dev @@ -81,3 +81,6 @@ ssh_support="y" # # This setting is used during virtual machine bootstrapping by kvmx-create. ssh_custom="y" + +# Bootloader (used only during bootstrapping by kvmx-create). +bootloader="grub" |