echo "Guest $VM was not running, so starting it anyway..."
kvmx_start
else
+ #if [ "$ssh_support" != "y" ]; then
+ # echo sudo reboot | kvmx_ssh
+ # exit
+ #fi
+
echo "Powering off guest $VM..."
kvmx_poweroff
exit 1
fi
+ if [ "$qcow2_compression" != "0" ]; then
+ $compression = "-c"
+ fi
+
# Size before compression
local size_before_bytes="`du $image | awk '{ print $1 }'`"
local size_before_human="`du -h $image | awk '{ print $1 }'`"
- qemu-img convert -O qcow2 -p -c $image $image.new && mv $image.new $image || exit 1
+ qemu-img convert -O qcow2 -p $compression $image $image.new && mv $image.new $image || exit 1
# Size after compression
local size_after_bytes="`du $image | awk '{ print $1 }'`"
kvmx_user_config domain example.org "Domain"
kvmx_user_config arch amd64 "System arch"
kvmx_user_config version stretch "Distro version"
- kvmx_user_config mirror http://http.debian.net/debian/ "Debian mirror"
+ kvmx_user_config mirror https://deb.debian.org/debian/ "Debian mirror"
kvmx_user_config ssh_support y "Administration using passwordless SSH (y/n)"
kvmx_user_config ssh_custom y "Setup a custom SSH keypair (y/n)"
kvmx_user_config user user "Initial user name"
kvmx_user_config size 3G "Image size"
kvmx_user_config format qcow2 "Image format: raw or qcow2"
+
+ if [ "$format" == "qcow2" ]; then
+ kvmx_user_config qcow2_compression y "Image compression (y/n)"
+ fi
+
kvmx_user_config method custom "Bootstrap method: custom or vmdeboostrap"
kvmx_user_config bootloader grub "Bootloader: grub or extlinux"
}
# Image format
if [ "$format" == "qcow2" ]; then
format="--convert-qcow2"
+
+ if [ "$qcow2_compression" == "y" ]; then
+ compression="-c"
+ fi
fi
if [ "$booloader" == "grub" ]; then
fi
# Check for requirements.
+ #for req in debootstrap parted apt-transport-https; do
for req in debootstrap parted; do
kvmx_install_package $req
done
# Initial system install.
echo "Installing base system..."
kvmx_sudo_run LC_ALL=C DEBIAN_FRONTEND=noninteractive debootstrap \
- --arch=$arch $version $WORK/ $mirror
+ --force-check-gpg --arch=$arch $version $WORK/ $mirror
# Initial configuration.
echo "Applying initial configuration..."
$APT_INSTALL grub-pc
# Serial console support
- echo '' >> $WORK/etc/default/grub
- echo '# Custom configuration' >> $WORK/etc/default/grub
- echo 'GRUB_TERMINAL=serial' >> $WORK/etc/default/grub
- echo 'GRUB_SERIAL_COMMAND="serial --speed=115200"' >> $WORK/etc/default/grub
- echo 'GRUB_CMDLINE_LINUX="console=ttyS0,115200n8"' >> $WORK/etc/default/grub
+ echo '' | $SUDO tee -a $WORK/etc/default/grub > /dev/null
+ echo '# Custom configuration' | $SUDO tee -a $WORK/etc/default/grub > /dev/null
+ echo 'GRUB_TERMINAL=serial' | $SUDO tee -a $WORK/etc/default/grub > /dev/null
+ echo 'GRUB_SERIAL_COMMAND="serial --speed=115200"' | $SUDO tee -a $WORK/etc/default/grub > /dev/null
+ echo 'GRUB_CMDLINE_LINUX="console=ttyS0,115200n8"' | $SUDO tee -a $WORK/etc/default/grub > /dev/null
kvmx_sudo_run chroot $WORK/ update-grub
kvmx_sudo_run chroot $WORK/ grub-install $device
if [ "$format" == "qcow2" ]; then
echo "Converting raw image to qcow2..."
kvmx_sudo_run mv $image $image.raw
- kvmx_sudo_run qemu-img convert -O qcow2 ${image}.raw $image
+ kvmx_sudo_run qemu-img convert -O qcow2 -p $compression ${image}.raw $image
kvmx_sudo_run rm ${image}.raw
fi