PXE Boot Server Installation Steps in Ubuntu Server VM
Solution 1:
PXE (Preboot eXecution Environment, pronounced pixie)
See Wikipedia: PXE
How it works?
This is my understanding!
- Client machine is powered on. BIOS scans for devices. Then it follows by trying to load boot-loader from required device as listed in Boot Order/Sequence. It loads PXE from network card ROM.
-
PXE (client side) broadcast a request for an IP. DHCP server reply with the required information: IP, Next Server IP (TFTP server IP),
pxelinux.0
(PXE bootstrap loader file name), ...etc -
PXE (client side) requests
pxelinux.0
file from TFTP server, loads it to RAM then passes control topxelinux.0
.pxelinux.0
gets boot configuration file from TFTP server with name as:
(if it doesn't exist it tries with the next)- UUID
- MAC
- IP in Capital Hex
- A portion of the IP
- Drops to
default
file
-
Either user choice or default menu entry.
pxelinux.0
requests the corresponding kernel and RAMDisk from the TFTP server and loads them to RAM.Then passes boot parameters and control to the loaded kernel.
-
Kernel loads the remaining parts from TFTP server or any other protocol server depending its features/properties.
Server Setup
There are many ways to setup PXE server, this is one of them.
These instructions were tested on Ubuntu 9.10 & Ubuntu 10.04 on a real machine. They should be still valid with only few changes may be. (Updated & Tested for Ubuntu 14.04 on VirtualBox , check edit revisions for old releases)
My target was PartedMagic 4.5, it should be similar to Ubuntu or any Linux distribution.
-
Install DHCP & TFTP packages
sudo apt-get install isc-dhcp-server openbsd-inetd lftp tftpd-hpa syslinux
-
DHCP Setup
-
Edit
/etc/default/isc-dhcp-server
, Ethernet interface for DHCP serviceINTERFACES="eth0"
-
Edit
/etc/dhcp/dhcpd.conf
or/etc/ltsp/dhcpd.conf
it does exist, DHCP service configurationPXE specific configurations:
filename
&next-server
default-lease-time 600; max-lease-time 7200; subnet 192.168.10.0 netmask 255.255.255.0 { range 192.168.10.50 192.168.10.100; option subnet-mask 255.255.255.0; option routers 192.168.10.123; option broadcast-address 192.168.10.255; filename "pxelinux.0"; next-server 192.168.10.123; }
-
Setup a static IP for
eth0
,192.168.10.123
in my case using network manager for Desktop edition or/etc/network/interfaces
for Server edition.auto eth0 iface eth0 inet static address 192.168.10.123 netmask 255.255.255.0 network 192.168.10.0 broadcast 192.168.10.255
Reinitialize the network interface:
sudo ifdown eth0 sudo ifup eth0
-
Re-start service
sudo service isc-dhcp-server restart
Check status
netstat -lu
Output
Proto Recv-Q Send-Q Local Address Foreign Address State udp 0 0 *:bootpc *:*
-
-
TFTP Setup
-
Edit
/etc/inetd.conf
, remove#<off>#
from the beginning oftftp
line or add if it not there under#:BOOT:
comment. (Skip this with systemd, 15.10 and later)tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot
-
Enable boot service for
inetd
sudo update-inetd --enable BOOT
-
Start service
sudo service openbsd-inetd restart sudo service tftpd-hpa restart
Check status
netstat -lu
Output
Proto Recv-Q Send-Q Local Address Foreign Address State udp 0 0 *:tftp *:*
-
-
PXE boot files setup
-
Unzip
pmagic-pxe-4.5.zip
. Ifpxelinux.0
is not there, get it fromsysliux-common
package installed at/usr/lib/syslinux/pxelinux.0
, Syslinux Project or Ubuntu Netboot Image.Put them in similar structure.
/var/lib/tftpboot/ |-- pxelinux.0 |-- pxelinux.cfg/ | `-- default `-- pmagic/ |-- bzimage `-- initramfs
-
Edit
/var/lib/tftpboot/pxelinux.cfg/default
, if needed example paths:pmagic/bzimage
&pmagic/initramfs
DEFAULT partmagic LABEL partmagic MENU LABEL PartMagic 4.5 KERNEL pmagic/bzimage APPEND initrd=pmagic/initramfs edd=off noapic load_ramdisk=1 prompt_ramdisk=0 rw vga=791 sleep=10 loglevel=0 keymap=us livemedia
-
Setup correct permissions
sudo find /var/lib/tftpboot -type f -exec chmod 644 {} \; sudo find /var/lib/tftpboot -type d -exec chmod 755 {} \;
-
Client Setup
Change BIOS boot order for one time using F9 or F12, for permanent setup from BIOS configuration DEL,F2 or F12. (Depending on machine brand)
Move to the top: [PXE | NIC | LAN | Ethernet | Network]
.
Notes
inetutils-inetd
orxinetd
can be used instead ofopenbsd-inetd
, someinetd
steps are different.TFTP root directory could be change from
/etc/default/tftpd-hpa
. Remember to update/etc/inetd.conf
too.Many distribution support loading RAMDisk through many protocols: SSH(SFTP), SMB, NFS ... Example Ubuntu support NFS.
-
Some old network cards do not support PXE, iPXE (Ex. gPXE or Etherboot) can be used, either on floppy disk, USB drive, Harddisk (
/boot
partition) or even flash it to ROM (only few NIC supported). GRUB2 has module to support booting using PXE.See also Wikipedia: gPXE and ROM-O-matic.
-
Ubuntu Netboot Image from cdimage.ubuntu.com/netboot/ provides installing Ubuntu from network and it will ask to download all required packages from the official mirror or a local one if you have one.
Most users are looking for booting live image through PXE. This question was only to setup a PXE server. See Ubuntu Wiki: Installation - LocalNet
-
PXE Menu can be customized, best template to learn from is Ubuntu NetBoot. See Pxeboot Multiple image
-
memdisk
can be used to load directly the ISO or floppy disk images through PXE.syslinux-common
package has a copy. Client should have enough RAM to hold the image plus a portion for running the loaded OS.Configuration example:
/var/lib/tftpboot/ |-- FDSTD.144 |-- memdisk |-- pxelinux.0 |-- slitaz-cooking.iso |-- pxelinux.cfg | `-- default `-- pmagic/ |-- bzimage `-- initramfs
/pxelinux.cfg/default
DEFAULT partmagic LABEL partmagic MENU LABEL PartMagic 4.5 KERNEL pmagic/bzimage APPEND initrd=pmagic/initramfs edd=off noapic load_ramdisk=1 prompt_ramdisk=0 rw vga=791 sleep=10 loglevel=0 keymap=us livemedia LABEL slitaz MENU LABEL ^Slitaz.iso TEXT HELP Testing boot from iso. ENDTEXT KERNEL memdisk APPEND initrd=slitaz-cooking.iso LABEL freedos_std MENU LABEL ^FreeDOS STD TEXT HELP Testing boot from Floppy IMG. ENDTEXT KERNEL memdisk APPEND initrd=FDSTD.144
PartedMagic packages were dropped from the official site after original developer decided to make it commercial, some releases could be found through torrent network. My answer here is a resume of first PXE setup that worked for me. Ubuntu Netboot Image should work with same instructions.