docs/PXE-boot.md
78281afa
 # Network PXE Boot
4d808912
 
e80d434b
 Photon OS supports the Preboot Execution Environment, or PXE, over a network connection. This document describes how to set up a PXE boot server to install Photon OS.
4d808912
 
78281afa
 # Server Setup
4d808912
 
e80d434b
 To set up a PXE server, you will need to have the following:
4d808912
 
e80d434b
 * A DHCP server to allow hosts to get an IP address.
 * A TFTP server, which is a file transfer protocol similar to FTP with no authentication.
 * Optionally, an HTTP server. The HTTP server will serve the RPMs yum repo, or you can use the official Photon OS repo on Bintray. Also, this HTTP server can be used if you want to provide a kickstart config for unattended installation.
 
 The instructions to set up the servers assume you have an Ubuntu 14.04 machine with a static IP address of `172.16.78.134`.
4d808912
 
78281afa
 ## DHCP Setup
 * Install the DHCP server:
4d808912
 ```
   sudo apt-get install isc-dhcp-server
 ```
e80d434b
 * Edit the Ethernet interface in `/etc/default/isc-dhcp-server` to `INTERFACES="eth0"`
 * Edit the DHCP configuration in `/etc/dhcp/dhcpd.conf` to allow machines to boot and get an IP address via DHCP in the range `172.16.78.230 - 172.16.78.250`
4d808912
 ```
   subnet 172.16.78.0 netmask 255.255.255.0 {
     range 172.16.78.230 172.16.78.250;
     option subnet-mask 255.255.255.0;
     option routers 172.16.78.134;
     option broadcast-address 172.16.78.255;
     filename "pxelinux.0";
     next-server 172.16.78.134;
   }
 
 ```
e80d434b
 * Restart the DHCP server: 
4d808912
 ```
   sudo service isc-dhcp-server restart
 ```
 
78281afa
 ## TFTP Setup
e80d434b
 * Install the TFTP server:
4d808912
 ```
   sudo apt-get install tftpd-hpa
 ```
e80d434b
 * Enable the boot service and restart the service:
4d808912
 ```
   sudo update-inetd --enable BOOT
   sudo service tftpd-hpa restart
 ```
e80d434b
 
78281afa
 ## Optional: HTTP server setup
e80d434b
 
78281afa
 This step is only needed if you are planning to serve the ks (kickstart) config file through this server; refer to [Kickstart support](kickstart.md) for details.
4d808912
 * Serving your local yum repo.
 You can install apache http web server
 ```
 sudo apt-get install apache2
 ```
e80d434b
 Mount the Photon iso to get the RPMS repo and sample ks config file.
4d808912
 ```
 mkdir /mnt/photon-iso
 sudo mount <photon_iso> /mnt/photon-iso/
 ```
 Copy the RPMS repo.
 ```
 cp -r /mnt/photon-iso/RPMS /var/www/html/
 ```
e80d434b
 To support ks, you can copy the sample config file from the iso and edit it; refer to [Kickstart support](kickstart.md) for details.
4d808912
 ```
 cp /mnt/photon-iso/isolinux/sample_ks.cfg /var/www/html/my_ks.cfg
 ```
 
78281afa
 ## PXE boot files setup
e80d434b
 * Mount photon.iso to get Linux and initrd images:
4d808912
 ```
4cadb3a2
 mkdir /mnt/photon-iso
 sudo mount <photon_iso> /mnt/photon-iso/
4d808912
 ```
e80d434b
 * Setting the PXE boot files:
4d808912
 ```
4cadb3a2
 wget https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz
 tar -xvf syslinux-6.03.tar.gz
4d808912
 pushd /var/lib/tftpboot
4cadb3a2
 cp -r /mnt/photon-iso/isolinux/* .
 cp ~/syslinux-6.03/bios/com32/elflink/ldlinux/ldlinux.c32 .
 cp ~/syslinux-6.03/bios/com32/lib/libcom32.c32 .
 cp ~/syslinux-6.03/bios/com32/libutil/libutil.c32 .
 cp ~/syslinux-6.03/bios/com32/menu/vesamenu.c32 .
 cp ~/syslinux-6.03/bios/core/pxelinux.0 .
4d808912
 mkdir pxelinux.cfg
 mv isolinux.cfg pxelinux.cfg/default
 ```
e80d434b
 * Update repo param to point to http yum repo; you may pass official photon bintray repo.
4d808912
 ```
 sed -i "s/append/append repo=http:\/\/172.16.78.134\/RPMS/g" menu.cfg
 popd
 ```
e80d434b
 * Optionally, you can add your ks config file; see [Kickstart support](kickstart.md) for details.
4cadb3a2