New article for the Network Debian install medium

This commit is contained in:
Thomas Schwery 2017-03-12 22:29:14 +01:00
parent b88849b2d5
commit ef17695de0

View file

@ -0,0 +1,97 @@
---
title: Network Debian Install
date: 2017-03-12 22:00:00
---
This is a follow-up of the previous *Preseeded Debian Install* article,
this time to add the capability of asking for a headless install through
SSH.
I received every part of my future storage server and needed to install
Debian on it. As I did not want to hook up a keyboard and display on it
just to install the OS, I looked into the Debian Installer *Network Console*.
The concept is really simple, as always: The installer can be seeded through
the first parts of the installation until the network is available and
then let the user continue through SSH.
First I needed to add a new entry in the ISOLINUX menu that can be selected.
```
cat >> isolinux/txt.cfg <<EOE
label install-stretch-netinstall
menu label ^Install Stretch $TARGETNAME (netinstall)
kernel /install.amd/vmlinuz
append vga=788 initrd=/install.amd/initrd.gz auto=true file=/cdrom/preseed-stretch-netboot.cfg
EOE
```
For now, the entry is not automatically selected, nor booting automatically
if the user does nothing. As this is not really useful for a headless,
we need to configure it so that it is automatically selected and boots after
a timeout.
Setting a timeout at something more than 0 enables the automatic boot of
the default entry. As the Debian ISO ship with no timeout, the script has
to set this timeout to something more, such as 5 seconds. As there are
multiple files that contains a timeout, I opted for a broad replace in
the configuration files. I also deleted the default entry so that our
new entry can be selected and executed.
```
perl -pi -e 's/timeout 0/timeout 50/' isolinux/*.cfg
perl -pi -e 's/\s*menu default//' isolinux/*.cfg
```
Next I needed to check which questions needed answering and which questions
are asked later during the installation. For that I trimmed my generated
preseed file from before until the installer got to the network part. I
got the following minimal preseed :
```
d-i debian-installer/language string en
d-i debian-installer/country string GB
d-i debian-installer/locale string en_GB.UTF-8
d-i keyboard-configuration/xkb-keymap select ch(fr)
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string newdebian
d-i netcfg/get_domain string
```
Then, I needed to enable the *Network Console* so that I can log into
the installer to continue. After looking through some documentations (and
some contradictory information), I got the following lines:
```
d-i debian-installer/language string en
d-i debian-installer/country string GB
d-i debian-installer/locale string en_GB.UTF-8
d-i keyboard-configuration/xkb-keymap select ch(fr)
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string newdebian
d-i netcfg/get_domain string
d-i netcfg/get_nameservers string
d-i netcfg/get_ipaddress string
d-i netcfg/get_netmask string 255.255.255.0
d-i netcfg/get_gateway string
d-i preseed/early_command string anna-install network-console
d-i network-console/password password install
d-i network-console/password-again password install
d-i network-console/start select continue
```
Now, once the USB device is inserted, the computer will boot on it, wait
5 seconds for an user input that will not come, execute the Installer
passing it the NetworkInstall preseed, configure the first steps and then
wait for a user to connect by SSH `ssh installer@<IP>` with the `install`
password.
The script is available on my [Git repository](https://bitbucket.org/tschwery/debian-preseeded-iso)
and will be kept updated as needed.