PXE boot server

From Christoph's Personal Wiki
Jump to: navigation, search

This article will show how to setup a PXE boot server running on top of a base Ubuntu 14.04 server. This process will require a DHCP server on your local network. This DHCP server does not necessarily need to be running on the same PXE install server, however, I will have both (DHCP and PXE) on the same Ubuntu server.

For this simple example, I will have the PXE boot server serve up only a CoreOS install. I will use dnsmasq instead of dhcpd. My local network will be

  • Install the following packages:
$ apt-get install -y tftpd-hpa inetutils-inetd dnsmasq apache2 syslinux syslinux-common
  • Make the /etc/default/tftpd-hpa file contain only the following lines:
OPTIONS="-l -s /var/lib/tftpboot"
  • Add the following line to the /etc/inetd.conf file:
tftp    dgram   udp    wait    root    /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot
  • Start/restart the tftpd-hpa service:
$ service tftpd-hpa restart
  • Make the /etc/dnsmasq.conf file contain only the following lines:
dhcp-host=ff:ff:ff:ff:ff:ff, # eth0 mac addr,ip
dhcp-option=3, # gateway (see: rfc 2132)
  • Start/restart the dnsmasq service:
$ service dnsmasq restart
  • Setup the tftp boot directory tree for PXE/CoreOS:
$ mkdir -p /var/lib/tftpboot/pxelinux/pxelinux.cfg/
$ ln -s /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot/pxelinux/pxelinux.0
  • Download the latest stable release of CoreOS PXE image:
$ cd /var/lib/tftpboot/pxelinux
$ wget http://stable.release.core-os.net/amd64-usr/current/coreos_production_pxe.vmlinuz
$ wget http://stable.release.core-os.net/amd64-usr/current/coreos_production_pxe.vmlinuz.sig
$ wget http://stable.release.core-os.net/amd64-usr/current/coreos_production_pxe_image.cpio.gz
$ wget http://stable.release.core-os.net/amd64-usr/current/coreos_production_pxe_image.cpio.gz.sig
$ gpg --verify coreos_production_pxe.vmlinuz.sig
$ gpg --verify coreos_production_pxe_image.cpio.gz.sig
  • The /var/lib/tftpboot/ directory tree should look like the following:
└── pxelinux
    ├── coreos_production_pxe_image.cpio.gz
    ├── coreos_production_pxe_image.cpio.gz.sig
    ├── coreos_production_pxe.vmlinuz
    ├── coreos_production_pxe.vmlinuz.sig
    ├── pxelinux.0
    └── pxelinux.cfg
        └── default
  • Setup your localhost Apache server to serve up your cloud-config.yml file:
$ cat << EOF >/var/www/html/cloud-config.yml
  • Create your PXE boot menu:
$ cat << EOF >/var/lib/tftpboot/pxelinux/pxelinux.cfg/default 
default coreos
prompt 1
timeout 15

display boot.msg

label coreos
  menu default
  kernel coreos_production_pxe.vmlinuz
  append initrd=coreos_production_pxe_image.cpio.gz cloud-config-url=

You should now be able to PXE boot another server on your local network, have you DHCP assign a local IP, and automatically boot up using the CoreOS install.