diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2018-01-02 22:04:07 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2018-01-02 22:04:07 -0200 |
commit | 7441b792e197734b85f7c01a64397fb97a267128 (patch) | |
tree | 9e75019a3ed39e556a42d817c12605d29d2138f6 /kvmx-create | |
parent | 6207b570cf9bc67fb0988ce91f5c79e6430c0acc (diff) | |
download | kvmx-7441b792e197734b85f7c01a64397fb97a267128.tar.gz kvmx-7441b792e197734b85f7c01a64397fb97a267128.tar.bz2 |
Adds qcow2_compression config, use https://deb.debian.org/debian/ mirror when possible
Diffstat (limited to 'kvmx-create')
-rwxr-xr-x | kvmx-create | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/kvmx-create b/kvmx-create index cdf3278..3071346 100755 --- a/kvmx-create +++ b/kvmx-create @@ -109,7 +109,7 @@ function kvmx_config { 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" @@ -124,6 +124,11 @@ function kvmx_config { 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" } @@ -155,6 +160,10 @@ function kvmx_create_vmdebootstrap { # Image format if [ "$format" == "qcow2" ]; then format="--convert-qcow2" + + if [ "$qcow2_compression" == "y" ]; then + compression="-c" + fi fi if [ "$booloader" == "grub" ]; then @@ -208,6 +217,7 @@ function kvmx_create_custom { fi # Check for requirements. + #for req in debootstrap parted apt-transport-https; do for req in debootstrap parted; do kvmx_install_package $req done @@ -232,7 +242,7 @@ function kvmx_create_custom { # 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..." @@ -288,11 +298,11 @@ function kvmx_create_custom { $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 @@ -336,7 +346,7 @@ EOF 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 |