Skip to content

Commit

Permalink
update for debian 12 bookworm
Browse files Browse the repository at this point in the history
  • Loading branch information
pin committed Jun 17, 2023
1 parent e90e33f commit c8067b3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 28 deletions.
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -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**
Expand All @@ -20,16 +16,16 @@ Guest OS is minimal no-GUI Debian installation configured with serial console
for ability to `virsh console <GUEST_NAME>`, 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
------------------------------------
Expand All @@ -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 <GUEST_NAME>` 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 <your_favorite>` or whatever you want to `postinst.sh`
`install.sh` and modify them as needed.
* Add `apt-get install -y <your_favorite>` 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`:
```
Expand Down
10 changes: 4 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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 ]
Expand Down Expand Up @@ -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 \
Expand Down
5 changes: 5 additions & 0 deletions postinst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions preseed.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <domain>` 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.
Expand Down

0 comments on commit c8067b3

Please sign in to comment.