PXE boot server

From Christoph's Personal Wiki
Revision as of 22:24, 12 December 2015 by Christoph (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 10.0.0.10/23.

  • 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:
RUN_DAEMON="yes"
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:
domain=coreos.example.dev
interface=eth0
dhcp-range=10.0.0.11,10.0.0.50,12h
dhcp-host=ff:ff:ff:ff:ff:ff,10.0.0.10 # eth0 mac addr,ip
dhcp-option=3,10.0.0.1 # gateway (see: rfc 2132)
dhcp-boot=pxelinux/pxelinux.0
enable-tftp
tftp-root=/var/lib/tftpboot
  • 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:
/var/lib/tftpboot/
└── 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
#cloud-config
...
EOF
  • 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=http://10.0.0.10/cloud-config.yml
EOF

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.