This article will describe installing tftpd/dhcpd and running PXE boot server for automated install. Automated installed OS are Debian 8 and Ubuntu 16.04.
Table of Contents
1 System environment
IP address of PXE boot server is 192.168.11.66.
MAC address of clients are 08:00:27:6c:29:8b and 52:54:00:01:14:cb.
2 Install tftpd
In case of Ubuntu 16.04, install tftpd-hpa with apt and then /var/lib/tftpboot is exported by default.
$ sudo apt install -y tftpd-hpa # atftpd on Debian 8 $ sudo systemctl enable tftpd-hpa # atftpd on Debian 8 $ sudo systemctl restart tftpd-hpa # atftpd on Debian 8
In case of Debian 8, install atftpd with apt and then /srv/tftp is exported by default.
$ sudo apt install -y atftpd $ sudo systemctl enable atftpd $ sudo systemctl restart atftpd
Please replace ${tftpboot_dir} to /var/lib/tftpboot or /srv/tftp from this.
3 Install dhcpd
Install isc-dhcp-server with apt.
$ sudo apt-get install -y isc-dhcp-server
Edit /etc/dhcp/dhcpd.conf for providing DNS, routing, IP address and boot file image name with filename directive.
$ sudo su -c 'cat <<EOF > /etc/dhcp/dhcpd.conf subnet 192.168.11.0 netmask 255.255.255.0 { option domain-name "hiroom2.com"; option domain-name-servers 192.168.11.2, 192.168.11.1; option routers 192.168.11.1; filename "pxelinux.0"; } host debian-8-pxeboot { hardware ethernet 08:00:27:6c:29:8b; fixed-address 192.168.11.129; } host ubuntu-16.04-pxeboot { hardware ethernet 52:54:00:01:14:cb; fixed-address 192.168.11.128; } EOF '
Run isc-dhcp-server with systemd.
$ sudo systemctl enable isc-dhcp-server $ sudo systemctl restart isc-dhcp-server
4 Download netboot image
Download netboot image of Debian 8 and copy to ${tftpboot_dir}.
$ wget http://ftp.debian.org/debian/dists/jessie/main/installer-amd64/current/images/netboot/netboot.tar.gz -O debian-8-netboot.tar.gz $ mkdir debian-8-netboot $ tar zxf debian-8-netboot.tar.gz -C debian-8-netboot $ sudo cp -a debian-8-netboot/debian-installer ${tftpboot_dir}
Download netboot image of Ubuntu 16.04 and copy to ${tftpboot_dir}.
$ wget http://archive.ubuntu.com/ubuntu/ubuntu/dists/xenial/main/installer-amd64/current/images/netboot/netboot.tar.gz -O ubuntu-16.04-netboot.tar.gz $ mkdir ubuntu-16.04-netboot $ tar zxf ubuntu-16.04-netboot.tar.gz -C ubuntu-16.04-netboot $ sudo cp -a ubuntu-16.04-netboot/ubuntu-installer ${tftpboot_dir}
5 pxelinux configuration
This article will use pxelinux contained in netboot image instead of installing pxelinux package with apt.
${tftpboot_dir} has files as below.
pxelinux.0 | boot file image |
ldlinux.c32 | library used by pxelinux.0 |
pxelinux.cfg/default | symbolic link to syslinux.cfg |
boot-screens/syslinux.cfg | pxelinux.0 configuration file |
boot-screens/menu.cfg | boot menu |
boot-screens/vesamenu.c32 | VESA program |
boot-screens/libcom32.c32 | library used by vesamenu.c32 |
boot-screens/libutil.c32 | library used by vesamenu.c32 |
debian-installer | Debian 8 installer |
ubuntu-installer | Ubuntu 16.04 installer |
boot-screens/syslinux.cfg and boot-screens/menu.cfg are created, and other is copied from netboot image.
$ sudo cp ubuntu-16.04-netboot/ubuntu-installer/amd64/pxelinux.0 ${tftpboot_dir}/ $ sudo cp ubuntu-16.04-netboot/ubuntu-installer/amd64/boot-screens/ldlinux.c32 ${tftpboot_dir}/ $ sudo mkdir ${tftpboot_dir}/boot-screens $ sudo cp ubuntu-16.04-netboot/ubuntu-installer/amd64/boot-screens/libcom32.c32 ${tftpboot_dir}/boot-screens $ sudo cp ubuntu-16.04-netboot/ubuntu-installer/amd64/boot-screens/libutil.c32 ${tftpboot_dir}/boot-screens $ sudo cp ubuntu-16.04-netboot/ubuntu-installer/amd64/boot-screens/vesamenu.c32 ${tftpboot_dir}/boot-screens $ sudo mkdir ${tftpboot_dir}/pxelinux.cfg $ cd ${tftpboot_dir}/pxelinux.cfg $ sudo ln -s ../boot-screens/syslinux.cfg default
5.1 boot-screens/syslinux.cfg
Load boot-screens/menu.cfg and vesamenu.c32. After 10 seconds without any keyboard input, Debian 8 install at top boot menu will be started.
$ sudo su -c "cat <<EOF > ${tftpboot_dir}/boot-screens/syslinux.cfg path boot-screens include boot-screens/menu.cfg default boot-screens/vesamenu.c32 prompt 0 timeout 100 EOF "
5.2 boot-screens/menu.cfg
Display menu as below.
- Debian 8 automated install
- Ubuntu 16.04 automated install
- Debian 8 manual install
- Ubuntu 16.04 manual install
automated install is implemented with preseed.
$ sudo su -c "cat <<EOF > ${tftpboot_dir}/boot-screens/menu.cfg menu hshift 13 menu width 49 menu margin 8 menu tabmsg menu title Installer boot menu label auto-debian-8 menu label ^Debian 8 automated install kernel debian-installer/amd64/linux append auto=true priority=critical vga=788 initrd=debian-installer/amd64/initrd.gz preseed/url=tftp://192.168.11.66/preseed/debian-8-preseed.cfg label auto-ubuntu-16.04 menu label ^Ubuntu 16.04 automated install kernel ubuntu-installer/amd64/linux append auto=true priority=critical vga=788 initrd=ubuntu-installer/amd64/initrd.gz preseed/url=tftp://192.168.11.66/preseed/ubuntu-16.04-preseed.cfg preseed/interactive=false menu begin debian-8 menu title Debian 8 label mainmenu menu label ^Back.. menu exit include debian-installer/amd64/boot-screens/menu.cfg menu end menu begin ubuntu-16.04 menu title Ubuntu 16.04 label mainmenu menu label ^Back.. menu exit include ubuntu-installer/amd64/boot-screens/menu.cfg menu end EOF "
6 preseed configuration
The preseed provides automated install with configuration files in ${tftpboot_dir}/preseed directory.
$ sudo mkdir ${tftpboot_dir}/preseed
6.1 preseed configuration file for Ubuntu 16.04
root password is "ubuntu".
User "ubuntu" is added and "ubuntu" password is "ubuntu".
Install unity, ubuntu-desktop and openssh-server.
Please change debian-installer/country and time/zone to yours.
$ sudo su -c "cat <<EOF > ${tftpboot_dir}/preseed/ubuntu-16.04-preseed.cfg d-i debian-installer/locale string en_US d-i debian-installer/language string en d-i debian-installer/country string JP d-i keyboard-configuration/xkb-keymap select jp106 d-i passwd/user-fullname string d-i passwd/username string ubuntu d-i passwd/root-password password ubuntu d-i passwd/root-password-again password ubuntu d-i passwd/user-password password ubuntu d-i passwd/user-password-again password ubuntu d-i user-setup/allow-password-weak boolean true d-i netcfg/choose_interface select auto d-i netcfg/get_hostname string unassigned-hostname d-i netcfg/get_domain string unassigned-domain d-i mirror/country string manual d-i mirror/http/hostname string http://jp.archive.ubuntu.com d-i mirror/http/directory string /ubuntu d-i mirror/http/proxy string d-i clock-setup/utc boolean true d-i clock-setup/ntp boolean true d-i time/zone string Asia/Tokyo d-i partman/confirm boolean true d-i partman/choose_partition select finish d-i partman/confirm_nooverwrite boolean true d-i partman-auto/disk string /dev/[sv]da d-i partman-auto/method string lvm d-i partman-auto/choose_recipe select atomic d-i partman-lvm/device_remove_lvm boolean true d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm_nooverwrite boolean true d-i partman-auto-lvm/guided_size string max d-i partman-partitioning/confirm_write_new_label boolean true d-i grub-installer/grub2_instead_of_grub_legacy boolean true d-i grub-installer/only_debian boolean true d-i grub-installer/bootdev string /dev/[sv]da d-i pkgsel/update-policy select none d-i pkgsel/include string unity ubuntu-desktop openssh-server d-i finish-install/reboot_in_progress note EOF "
6.2 preseed configuration file for Debian 8
root password is "debian".
User "debian" is added and "debian" password is "debian".
Install gnome and openssh-server.
Please change debian-installer/country and time/zone to yours.
$ sudo su -c "cat <<EOF > ${tftpboot_dir}/preseed/debian-8-preseed.cfg d-i debian-installer/locale string en_US d-i debian-installer/language string en d-i debian-installer/country string JP d-i keyboard-configuration/xkb-keymap select jp106 d-i passwd/user-fullname string d-i passwd/username string debian d-i passwd/root-password password debian d-i passwd/root-password-again password debian d-i passwd/user-password password debian d-i passwd/user-password-again password debian d-i user-setup/allow-password-weak boolean true d-i netcfg/choose_interface select auto d-i netcfg/get_hostname string unassigned-hostname d-i netcfg/get_domain string unassigned-domain d-i mirror/country string manual d-i mirror/http/hostname string ftp.jp.debian.org d-i mirror/http/directory string /debian d-i mirror/http/proxy string d-i clock-setup/utc boolean true d-i clock-setup/ntp boolean true d-i time/zone string Asia/Tokyo d-i partman/confirm boolean true d-i partman/choose_partition select finish d-i partman/confirm_nooverwrite boolean true d-i partman-auto/disk string /dev/[sv]da d-i partman-auto/method string lvm d-i partman-auto/choose_recipe select atomic d-i partman-lvm/device_remove_lvm boolean true d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm_nooverwrite boolean true d-i partman-auto-lvm/guided_size string max d-i partman-partitioning/confirm_write_new_label boolean true d-i grub-installer/grub2_instead_of_grub_legacy boolean true d-i grub-installer/only_debian boolean true d-i grub-installer/bootdev string /dev/[sv]da d-i pkgsel/update-policy select none d-i pkgsel/include string gnome openssh-server d-i finish-install/reboot_in_progress note EOF "
7 Excecution result
In case of virt-manager, move "NIC" to top of "Boot device order".
If storage of virtual machine is empty, not needed to be at top.
In case of VirtualBox, move "Network" to top of "Boot order".
If storage of virtual machine is empty, not needed to be at top.
In case of real machine, please check BIOS menu.
DHCP negotiation starts after power on.
Menu of menu.cfg is displayed.
After 10 seconds without any keyboard input, Debian 8 automated install will be started.