📜 ⬆️ ⬇️

Installing Debian remotely: PXE + SSH

Task


Install Debian Lenny on a server that is located on a remote site.
The site already has one Linux-based server, and there is an engineer who can connect the new server to the network and turn it on.

Decision


Download the netinstall image on PXE and use the network-console package for installation using ssh.

On the Internet, as usual, there are a lot of fragments of documentation; I tried to put all this together.

On the existing server (for example, the same Debian Lenny will be installed there), we will need dhcp3-server, tftpd-hpa and any http-server.
')
Configure dhcp3-server:
 /etc/dhcp3/dhcpd.conf

 ddns-update-style none;
 option domain-name "local";
 option domain-name-servers 192.168.1.1;

 default-lease-time 600;
 max-lease-time 7200;

 authoritative;

 log facility local7;

 subnet 192.168.1.0 netmask 255.255.255.0 {
  option routers 192.198.1.1;
  option domain-name-servers 192.168.1.1;
  option domain-name "local";
  next-server 192.168.1.1;
  filename "pxelinux.0";
  range 192.168.1.100 192.168.1.250;
 }

The next-server option will give the PXE bootloader of the network card the IP address of the TFTP server, and the filename will give the name of the file with the linux bootloader.

TFTP does not need any special configuration, so we need to further configure the pxelinux bootloader config files, they are located in the /var/lib/tftpboot/pxelinux.cfg/default file. It should be of the following form:
 default lenny-ssh
 prompt 0
 label lenny-ssh
   kernel linux
   append initrd = initrd.gz locale = en_US console-keymaps-at / keymap = us netcfg / choose_interface = eth0 netcfg / get_hostname = debian netcfg / get_domain = local url = http: //192.168.1.1/preseed.cfg

Attention , indentation is important in this config!
If you have problems, you can enable debug by adding the option DEBCONF_DEBUG = 5

The pxelinux.0, linux and initrd.gz files are taken from the repository , there you can also find pxelinux.0 .

The preseed.cfg file should be like this:
 di mirror / country string manual
 di mirror / http / hostname string mirror.yandex.ru
 di mirror / http / directory string / debian
 di mirror / http / proxy string

 di network-console / password password r00tme
 di network-console / password-again password r00tme
 di preseed / early_command string anna-install network-console
 di anna / choose_modules string network-console

 tasksel tasksel / first multiselect none
 di pkgsel / include string openssh-server sudo screen
 di pkgsel / upgrade select full-upgrade

In all mana it includes options related to the settings of the locale and the network, it did not work for me, possibly due to the fact that the preseed.cfg file is connected after configuring these parameters, therefore, they should be passed as initrd options.

Actually, we turn on the new piece of hardware, look in the dhcp logs for the IP address that the host received, and connect to it via ssh with the installer login and password r00tme

By analogy, you can configure a fully automated installation by adding preseed.cfg. For me personally, this option is not convenient, since very often the servers have a different configuration of the disk subsystem and there is no single “recipe”.

Links

Official documentation
Second official instruction
Doc, who helped most , in Japanese

Source: https://habr.com/ru/post/103743/


All Articles