Skip to content

Commit c8067b3

Browse files
committed
update for debian 12 bookworm
1 parent e90e33f commit c8067b3

4 files changed

Lines changed: 32 additions & 28 deletions

File tree

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# Debian Stretch unattended VM guest installer
2-
3-
*While Debian Stretch is not released yet, script uses `daily-images`.
4-
If you want to use Debian Jessie (e.g. current stable) please check out
5-
release v8.0 or update DIST_URL*
1+
# Debian Bookworm unattended VM guest installer
62

73
Simple script that uses **virt-install** and configures Debian installer
84
for unattended installation and custom configuration using **preseed**
@@ -20,16 +16,16 @@ Guest OS is minimal no-GUI Debian installation configured with serial console
2016
for ability to `virsh console <GUEST_NAME>`, and OpenSSH server with your SSH
2117
key or/and password pre-configured.
2218

23-
It is easy to change the script to add any extra packages and configuration
24-
files during unattended installation.
25-
26-
Actually, the main point of sharing this script is to provide an example of
27-
unattended Debian VM creation or a base for your own script.
19+
It is easy to change the script to add any extra packages and
20+
configuration files during unattended installation. The main point of
21+
sharing this script is to provide an example of unattended Debian VM
22+
creation or a base for your own script.
2823

2924
Prerequisites
3025
-------------
31-
* virt-install: `apt-get install virtinst`
32-
* KVM/qemu: `apt-get install qemu-kvm libvirt-daemon # something else?`
26+
```
27+
apt-get install wget virtinst libvirt-daemon-system
28+
```
3329

3430
Things to check before the first use
3531
------------------------------------
@@ -41,19 +37,24 @@ Things to check before the first use
4137
Update your login name in `postinst.sh`, where SSH key is installed.
4238
* It's worth considering to enable password authentication in `preseed.cfg`
4339
at least during first run so you could `virsh console <GUEST_NAME>` in case
44-
network connection in guest does not comes up with DHCP or IP of the guest
40+
network connection in guest does not come up with DHCP or IP of the guest
4541
is unclear.
4642
* Check RAM size and disk size for the guest in arguments to `virst-install` in
47-
`install.sh` and modify them if needed.
48-
* Add `apt-get install <your_favorite>` or whatever you want to `postinst.sh`
43+
`install.sh` and modify them as needed.
44+
* Add `apt-get install -y <your_favorite>` or whatever you want to `postinst.sh`
4945
and any configuration files you want to add to the guest into `postinst`
5046
directory.
5147

5248
Network configuration
5349
---------------------
54-
Script works best with bridged network, when guests are able to use DHCP
55-
server. In case you want something else, replace `br0` in arguments to
56-
virt-install in `install.sh`.
50+
Script works with bridged network, guests use DHCP and show up in local network.
51+
In case you want something else, replace `br0` in arguments to virt-install
52+
in `install.sh`.
53+
54+
Before setting bridged network up:
55+
```
56+
apt-get install brigde-utils
57+
```
5758

5859
Example of network configuration in `/etc/network/interfaces`:
5960
```

install.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
#!/bin/sh -e
22

3-
# A script to create debian VM as a KVM guest using virt-install in fully
3+
# Create debian VM as a KVM guest using virt-install in fully
44
# automated way based on preseed.cfg
55

6-
# Domain is necessary in order to avoid debian installer to
6+
# Domain is necessary to avoid debian installer to
77
# require manual domain entry during the install.
88
DOMAIN=`/bin/hostname -d` # Use domain of the host system
99
#DOMAIN="dp-net.com" # Alternatively, hardcode domain
1010
# NB: See postinst.sh for ability to override domain received from
1111
# DHCP during the install.
1212

13-
#DIST_URL="http://ftp.de.debian.org/debian/dists/stretch/main/installer-amd64/"
14-
DIST_URL="https://d-i.debian.org/daily-images/amd64/"
15-
LINUX_VARIANT="debian9"
13+
DIST_URL="http://ftp.debian.org/debian/dists/bookworm/main/installer-amd64/"
14+
LINUX_VARIANT="debiantesting"
1615
# NB: Also see preseed.cfg for debian mirror hostname.
1716

1817
if [ $# -lt 1 ]
@@ -55,7 +54,6 @@ virt-install \
5554
--initrd-inject=postinst.sh \
5655
--initrd-inject=postinst.tar.gz \
5756
--location ${DIST_URL} \
58-
--os-type linux \
5957
--os-variant ${LINUX_VARIANT} \
6058
--virt-type=kvm \
6159
--controller usb,model=none \

postinst.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,8 @@ DEBIAN_FRONTEND=noninteractive apt-get purge -y nano laptop-detect tasksel dicti
3434
# Avoid using DHCP-server provided domain name.
3535
#sed -i 's/#supersede.*/supersede domain-name "dp-net.com";/' /etc/dhcp/dhclient.conf
3636

37+
# Do not install recommended packages by default
38+
cat > /etc/apt/apt.conf.d/01norecommend << EOF
39+
APT::Install-Recommends "0";
40+
APT::Install-Suggests "0";
41+
EOF

preseed.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ d-i mirror/http/proxy string
1919
d-i passwd/root-login boolean false
2020
#d-i passwd/root-password password 98e1c23d2a5a2
2121
#d-i passwd/root-password-again password 98e1c23d2a5a2
22-
#d-i passwd/root-password-crypted password $6$1LCVFshS/kbYVg$M1QS1ZJ3.E7NkAD8sqkqhqExA2HWQ5/iDE.l23Xbr89Z7hTg/jUuBMyrYzANLmRybYcH8Smcy.yGDKMAX3okd0
22+
#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.
2323

2424
# User account setup.
2525
#d-i passwd/make-user boolean false
@@ -50,13 +50,13 @@ d-i partman/confirm_nooverwrite boolean true
5050
# Do not install recommended packages by default.
5151
d-i base-installer/install-recommends boolean false
5252
tasksel tasksel/first multiselect
53-
# Individual additional packages to install. acpid and acpi-support-base are required to make virsh shutdown to work.
53+
54+
# Individual additional packages to install.
5455
# ACPI packages are needed for `virsh shutdown <domain>` to work.
5556
d-i pkgsel/include string openssh-server ca-certificates acpid acpi-support-base
5657
popularity-contest popularity-contest/participate boolean false
5758

58-
# Boot loader installation.
59-
d-i grub-installer/only_debian boolean true
59+
# Bootloader installation.
6060
d-i grub-installer/bootdev string /dev/vda
6161

6262
# Run postinst.sh in /target just before the install finishes.

0 commit comments

Comments
 (0)