Because half of the articles I found querying the very title of this one involved, during the installation, to press a key or to write an address to pull the preceed.cfg
from the network – how is this headless ?!?! – and because debian documentation is certainly complete but a bit too spread out for the TL;DR era, I decided to share my simple recipe. In this guide, we will download an official Debian ISO, tune it and produce a custom ISO for an installation that requires no keyboard nor screen.
Download ISO and extract it
We will work in an iso
folder where we first extract a Debian ISO freshly downloaded.
mkdir iso
wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.10.0-amd64-netinst.iso
7z x debian-12.10.0-amd64-netinst.iso -oiso
The iso folder should look like this
boot
'[BOOT]'
css
dists
doc
...
Config files edition
To launch the automatic install and bypass the default speech assisted installation, we first need to remove the two following lines
include spkgtk.cfg
include spk.cfg
from iso/isolinux/menu.cfg
and edit iso/isolinux/txt.cfg
in such a way to automatically use the our future preseed.cfg
; like this:
default install
label install
menu label ^Install
menu default
kernel /install.amd/vmlinuz
append auto=true priority=critical vga=788 initrd=/install.amd/initrd.gz file=/cdrom/preseed.cfg --- quiet
Finally, in order to avoid the need for any prompt, we need to pass timeout
to 4
in the two following config files:
iso/isolinux/isolinux.cfg
iso/isolinux/prompt.cfg
Careful: Because of this last parameter, any machine BIOS of which is set to boot from an USB key will install Debian 12 without any confirmation.
Preceed.cfg setting
Let’s download Debian official example of this file in a local preceed.final
file
wget https://www.debian.org/releases/stable/example-preseed.txt -o preceed.final
Editing
This file basically contains all the parameters you could set during a manual install. There is plenty of documentation on the subject here. You might want, for instance, to
- set locales
d-i debian-installer/locale string fr_FR.UTF-8
# The values can also be preseeded individually for greater flexibility.
d-i debian-installer/language string fr
d-i debian-installer/country string FR
d-i debian-installer/locale string fr_FR.UTF-8
# Optionally specify additional locales to be generated.
#d-i localechooser/supported-locales multiselect en_US.UTF-8, nl_NL.UTF-8
so frenchy of me…
- configure your partitions with
d-i partman-auto/expert_recipe
- use custom repository mirrors
# If you select ftp, the mirror/country string does not need to be set.
# Default value for the mirror protocol: http.
#d-i mirror/protocol string ftp
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.fr.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
Trials and errors in a virtual machine is a good way to master Debian Preceed files
Packaging
We first copy our preceed.final
in the iso folder
cp preseed.final iso/preseed.cfg
but we also need to pack it in initrd.gz
. Here is a way to do it:
sudo mkdir irmod
cd irmod
sudo gzip -d < ../iso/install.amd/initrd.gz | \
sudo cpio --extract --make-directories --no-absolute-filenames
sudo cp ../preseed.final preseed.cfg
sudo chown root:root preseed.cfg
sudo chmod o+w ../iso/install.amd/initrd.gz
find . | cpio -H newc --create | \
gzip -9 > ../iso/install.amd/initrd.gz
sudo chmod o-w ../iso/install.amd/initrd.gz
cd ../
sudo rm -fr irmod/
ISO building
We first need to compute the hash of all the files to be packaged in the ISO with
md5sum $(find ./iso -type f ) > ./iso/md5sum.txt
and build out new ISO.
sudo genisoimage -o ./custom_install.iso -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat ./iso
Et voilĂ ! Your custom_install.iso is ready.