If you need to install Debian on several machines, then of course it is better to download and install it over the network. Well, I would like the installation to take place in a fully automatic mode. This will be the article. The main part of the article is a free retelling of the wiki Debian, but there are also a couple of nuances described here that are not covered in the wiki, but without them the installation will not be completely automatic.
To begin with, the network must have a DHCP / TFTP server. If not, you can first manually install it on one of the Debian machines and pick up on it DHCP and TFTP. To do this, install the packages dhcp3-server and tftpd-hpa. For DHCP, we will configure the distribution of addresses for the required subnet (hereinafter in examples 192.168.2.0/24) and information about which image should be loaded via TFTP.
An example of a simple dhcp3-server configuration file:
cat /etc/dhcp/dhcpd.conf | grep -v '#'
option domain-name-servers 8.8.8.8;
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.2.0 netmask 255.255.255.0
{
range 192.168.2.10 192.168.2.120;
option routers 192.168.2.1;
option domain-name "debianfarm.org";
filename "pxelinux.0";
host firstserver
{
option host-name "firstserver";
hardware ethernet 08:00:27:91:DA:57;
fixed-address 192.168.2.21;
}
}
PS In the example as the DNS is distributed Google Public DNS. All servers are located in the debianfarm.org domain, and for each, it is desirable to bind statically the IP and hostname on the MAC, although this is not necessary. In the example, this is done for only one host. Also, the TFTP server can be located on another host. To specify its address, add the option next-server <server>;
After editing the config, you need to restart the DHCP daemon:
# /etc/init.d/isc-dhcp-server restart
Now you need to download the necessary files and put them in the root for TFTP (by default / srv / tftp, although during the installation of the tftpd-hpa package you will be asked to choose another path).
# cd /srv/tftp
# wget mirror.yandex.ru/debian/dists/squeeze/main/installer-i386/current/images/netboot/netboot.tar.gz
# tar -xvf netboot.tar.gz
Edit the ./pxelinux.cfg/default file in the TFTP root so that the syslinux loader does not wait for the user to react after the download, and after a second he started the installation. To do this, set the timeout option to 1.
Now you need to add a debian-installer variable to the kernel parameters to load the preseed file. This file stores the values ​​of variables that are usually asked from the user during installation. That is, you create a file in advance with the “answers to the questions” of the Debian Installer (about its contents later). But there is one nuance that is not mentioned in the wiki: the preseed file is not loaded immediately after the installer has been launched, but only after some questions have been asked to the user, which means that using only the preseed file you cannot achieve a fully automatic installation. Therefore, the answers to the questions of the installer before loading preseed need to pass the parameters of the kernel boot, which then pick up the Debian installer. However, it would be possible to transfer to the kernel all the necessary "answers to the questions" of the installer, but you will not be allowed to create a limit on the maximum length of the kernel launch string.
Passing the values ​​of these variables to the kernel, you can omit the first part of the variable name (the one that comes before the slash with the slash). But this cannot be done for variables in which the second part of the name conflicts with another variable, for example:
console-keymaps-at / keymap must be specified completely, since there is also the variable console-keymaps-usb / keymap.
The syslinux config should now look something like this:
cat ./debian-installer/i386/boot-screens/txt.cfg
default install
label install
menu label ^Install
menu default
kernel debian-installer/i386/linux
append vga=788 initrd=debian-installer/i386/initrd.gz locale=en_US country=BY language=en console-keymaps-at/keymap=en url=http://192.168.2.1/preseed.cfg hostname=debian domain=debianfarm.org -- quiet
PS The host name here must be specified, but remember that the value later obtained by DHCP will have the highest priority. The same applies to the domain.
')
On the host 192.168.2.1 should be raised http-server. If not, you can install nginx, in the configuration file in the http section add something like this:
server
{
listen 80;
server_name localhost;
location /
{
root /path/to/dir/with/preseed/;
}
}
However, the preseed file can be placed anywhere (dropbox, etc.)
Now a little about the contents of the preseed file. An example of such a file can be found here
www.debian.org/releases/squeeze/example-preseed.txt . Here is the working version of the file:
di netcfg/choose_interface select auto
di netcfg/wireless_wep string
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 passwd/make-user boolean false
di passwd/root-password password juststrongpassword
di passwd/root-password-again password juststrongpassword
di clock-setup/utc boolean true
di time/zone string US/Eastern
di clock-setup/ntp boolean true
di partman-auto/method string lvm
di partman-lvm/device_remove_lvm boolean true
di partman-md/device_remove_md boolean true
di partman-lvm/confirm boolean true
di partman-auto/choose_recipe select atomic
di partman-partitioning/confirm_write_new_label boolean true
di partman/choose_partition select finish
di partman/confirm boolean true
di partman/confirm_nooverwrite boolean true
di partman-md/confirm boolean true
di partman-partitioning/confirm_write_new_label boolean true
di partman/choose_partition select finish
di partman/confirm boolean true
di partman/confirm_nooverwrite boolean true
tasksel tasksel/first multiselect standard
di pkgsel/include string openssh-server
popularity-contest popularity-contest/participate boolean false
di finish-install/reboot_in_progress note
There is no point in commenting here, for each variable duplicates extremely clear installer dialogues, for each one you can see the comment in the example.
The disk partitioning method was simply copied from the example, since it depends on the number of hard drives, their size and server needs.
Well, that's all, now it remains only to turn on those machines on which you need to install Debian, everything else will happen “by itself”.