diff --git a/README.md b/README.md index fba57d5..f4f1f3b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,4 @@ -# Debian Stretch unattended VM guest installer - -*While Debian Stretch is not released yet, script uses `daily-images`. -If you want to use Debian Jessie (e.g. current stable) please check out -release v8.0 or update DIST_URL* +# Debian Bookworm unattended VM guest installer Simple script that uses **virt-install** and configures Debian installer for unattended installation and custom configuration using **preseed** @@ -20,16 +16,16 @@ Guest OS is minimal no-GUI Debian installation configured with serial console for ability to `virsh console `, and OpenSSH server with your SSH key or/and password pre-configured. -It is easy to change the script to add any extra packages and configuration -files during unattended installation. - -Actually, the main point of sharing this script is to provide an example of -unattended Debian VM creation or a base for your own script. +It is easy to change the script to add any extra packages and +configuration files during unattended installation. The main point of +sharing this script is to provide an example of unattended Debian VM +creation or a base for your own script. Prerequisites ------------- - * virt-install: `apt-get install virtinst` - * KVM/qemu: `apt-get install qemu-kvm libvirt-daemon # something else?` +``` +apt-get install wget virtinst libvirt-daemon-system +``` Things to check before the first use ------------------------------------ @@ -41,19 +37,24 @@ Things to check before the first use Update your login name in `postinst.sh`, where SSH key is installed. * It's worth considering to enable password authentication in `preseed.cfg` at least during first run so you could `virsh console ` in case - network connection in guest does not comes up with DHCP or IP of the guest + network connection in guest does not come up with DHCP or IP of the guest is unclear. * Check RAM size and disk size for the guest in arguments to `virst-install` in - `install.sh` and modify them if needed. - * Add `apt-get install ` or whatever you want to `postinst.sh` + `install.sh` and modify them as needed. + * Add `apt-get install -y ` or whatever you want to `postinst.sh` and any configuration files you want to add to the guest into `postinst` directory. Network configuration --------------------- -Script works best with bridged network, when guests are able to use DHCP -server. In case you want something else, replace `br0` in arguments to -virt-install in `install.sh`. +Script works with bridged network, guests use DHCP and show up in local network. +In case you want something else, replace `br0` in arguments to virt-install +in `install.sh`. + +Before setting bridged network up: +``` +apt-get install brigde-utils +``` Example of network configuration in `/etc/network/interfaces`: ``` diff --git a/install.sh b/install.sh index 5d0e338..eecf05a 100755 --- a/install.sh +++ b/install.sh @@ -1,18 +1,17 @@ #!/bin/sh -e -# A script to create debian VM as a KVM guest using virt-install in fully +# Create debian VM as a KVM guest using virt-install in fully # automated way based on preseed.cfg -# Domain is necessary in order to avoid debian installer to +# Domain is necessary to avoid debian installer to # require manual domain entry during the install. DOMAIN=`/bin/hostname -d` # Use domain of the host system #DOMAIN="dp-net.com" # Alternatively, hardcode domain # NB: See postinst.sh for ability to override domain received from # DHCP during the install. -#DIST_URL="http://ftp.de.debian.org/debian/dists/stretch/main/installer-amd64/" -DIST_URL="https://d-i.debian.org/daily-images/amd64/" -LINUX_VARIANT="debian9" +DIST_URL="http://ftp.debian.org/debian/dists/bookworm/main/installer-amd64/" +LINUX_VARIANT="debiantesting" # NB: Also see preseed.cfg for debian mirror hostname. if [ $# -lt 1 ] @@ -55,7 +54,6 @@ virt-install \ --initrd-inject=postinst.sh \ --initrd-inject=postinst.tar.gz \ --location ${DIST_URL} \ ---os-type linux \ --os-variant ${LINUX_VARIANT} \ --virt-type=kvm \ --controller usb,model=none \ diff --git a/postinst.sh b/postinst.sh index 8d651e9..73a0453 100644 --- a/postinst.sh +++ b/postinst.sh @@ -34,3 +34,8 @@ DEBIAN_FRONTEND=noninteractive apt-get purge -y nano laptop-detect tasksel dicti # Avoid using DHCP-server provided domain name. #sed -i 's/#supersede.*/supersede domain-name "dp-net.com";/' /etc/dhcp/dhclient.conf +# Do not install recommended packages by default +cat > /etc/apt/apt.conf.d/01norecommend << EOF +APT::Install-Recommends "0"; +APT::Install-Suggests "0"; +EOF diff --git a/preseed.cfg b/preseed.cfg index b9d86f2..5728471 100644 --- a/preseed.cfg +++ b/preseed.cfg @@ -19,7 +19,7 @@ d-i mirror/http/proxy string d-i passwd/root-login boolean false #d-i passwd/root-password password 98e1c23d2a5a2 #d-i passwd/root-password-again password 98e1c23d2a5a2 -#d-i passwd/root-password-crypted password $6$1LCVFshS/kbYVg$M1QS1ZJ3.E7NkAD8sqkqhqExA2HWQ5/iDE.l23Xbr89Z7hTg/jUuBMyrYzANLmRybYcH8Smcy.yGDKMAX3okd0 +#d-i passwd/root-password-crypted password $6$1LCVFshS/kbYVg$M1QS1ZJ3.E7NkAD8sqkqhqExA2HWQ5/iDE.l23Xbr89Z7hTg/jUuBMyrYzANLmRybYcH8Smcy.yGDKMAX3okd0 # Use `mkpasswd -m sha-512` to generate password hash. # User account setup. #d-i passwd/make-user boolean false @@ -50,13 +50,13 @@ d-i partman/confirm_nooverwrite boolean true # Do not install recommended packages by default. d-i base-installer/install-recommends boolean false tasksel tasksel/first multiselect -# Individual additional packages to install. acpid and acpi-support-base are required to make virsh shutdown to work. + +# Individual additional packages to install. # ACPI packages are needed for `virsh shutdown ` to work. d-i pkgsel/include string openssh-server ca-certificates acpid acpi-support-base popularity-contest popularity-contest/participate boolean false -# Boot loader installation. -d-i grub-installer/only_debian boolean true +# Bootloader installation. d-i grub-installer/bootdev string /dev/vda # Run postinst.sh in /target just before the install finishes.