Print this Page

Home Server PXE Server

Index.

 

10-Jul-2011: initial release.
07-Feb-2012: removed TCP wrapper reference.

 

Introduction.

Our Home Server already has most tools available to add a PXE server. With a PXE server you can boot computers over the network and load software on them. This can be used for rescue software, installer CD’s etc. The components needed to build a PXE server are:

  1. dhcp – A DHCP server, client, and relay agent.
  2. nfsutils – Support programs for Network File Systems
  3. syslinux – Collection of boot loaders that boot from FAT, ext2/3/4 and btrfs filesystems, from CDs and via PXE.
  4. tftp-hpa – Official tftp server.
  5. xinetd – A secure replacement for inetd.

Install all packages:

[root@homsrv ~]# pacman -S --needed syslinux tftp-hpa xinetd
resolving dependencies...
looking for inter-conflicts...

Targets (3): syslinux-4.04-1  tftp-hpa-5.0-3  xinetd-2.3.14-6

Total Download Size:    0.86 MB
Total Installed Size:   3.94 MB

Proceed with installation? [Y/n]
:: Retrieving packages from core...
 syslinux-4.04-1-i686    770.3K  649.6K/s 00:00:01 [######################] 100%
 xinetd-2.3.14-6-i686     78.0K  355.2K/s 00:00:00 [######################] 100%
:: Retrieving packages from extra...
 tftp-hpa-5.0-3-i686      34.1K  212.8K/s 00:00:00 [######################] 100%
(3/3) checking package integrity                   [######################] 100%
(3/3) checking for file conflicts                  [######################] 100%
(1/3) installing syslinux                          [######################] 100%
==> If you want to use syslinux as your bootloader
==> edit /boot/syslinux/syslinux.cfg and run
==>   # /usr/sbin/syslinux-install_update -i -a -m
==> to install it.
Optional dependencies for syslinux
    perl-passwd-md5: For md5pass
    perl-digest-sha1: For sha1pass
    mtools: For mkdiskimage and syslinux
(2/3) installing tftp-hpa                          [######################] 100%
(3/3) installing xinetd                            [######################] 100%
Optional dependencies for xinetd
    perl: for xconv.pl script
[root@homsrv ~]#

 

Configure the DHCP server.

Add the following lines to /etc/dhcpd.conf:

# bootserver support
filename "pxelinux.0";
next-server 10.126.160.253;

 

Configure the NFS server.

While it is not strictly necesary, but some PXE images load faster when you use NFS instead of only tftp. One of these images is the System Rescue CD. Add the following line to /etc/exports:

/tftpboot    10.126.160.0/24(ro,no_subtree_check,all_squash)

 

Configure the inetd service.

Create the file /etc/xinetd.d/tftp:

service tftp
{
    disable = no
    socket_type = dgram
    protocol = udp
    wait = yes
    user = root
    server = /usr/sbin/in.tftpd
    server_args = -v -s /tftpboot -r blksize
}

Syslinux setup.

Copy the syslinux tools and (re)start all services:

[root@homsrv ~]# cd /usr/lib/syslinux/
[root@homsrv syslinux]# cp chain.c32 menu.c32 poweroff.com pxelinux.0 reboot.c32 \
   vesamenu.c32 /tftpboot/
[root@homsrv syslinux]# cd /tftpboot
[root@homsrv tftpboot]# ls -l
total 272
-rw-r--r-- 1 root root  20192 Jul 10 19:35 chain.c32
-rw-r--r-- 1 root root  56164 Jul 10 19:35 menu.c32
-rw-r--r-- 1 root root    239 Jul 10 19:35 poweroff.com
-rw-r--r-- 1 root root  26652 Jul 10 19:35 pxelinux.0
drwxr-xr-x 2 root root   4096 Jul 10 19:34 pxelinux.cfg
-rw-r--r-- 1 root root    800 Jul 10 19:35 reboot.c32
-rw-r--r-- 1 root root 155792 Jul 10 19:35 vesamenu.c32
[root@homsrv tftpboot]# /etc/rc.d/nfs-server restart
:: Stopping rpc.mountd daemon                                            [DONE]
:: Stopping rpc.nfsd daemon                                              [DONE]
:: Unexporting all directories                                           [DONE]
:: Mounting nfsd filesystem                                              [DONE]
:: Exporting all directories                                             [DONE]
:: Starting rpc.nfsd daemon                                              [DONE]
:: Starting rpc.mountd daemon                                            [DONE]
[root@homsrv tftpboot]# /etc/rc.d/dhcp4 restart
:: Stopping DHCPv4 Server                                                [DONE]
:: Starting DHCPv4 Server                                                [DONE]
[root@homsrv tftpboot]# /etc/rc.d/xinetd start
:: Starting xinetd                                                       [DONE]
[root@homsrv tftpboot]#

 

Syslinux menus.

Most menus are in /tftpboot/pxelinux.cfg. We use menus with an include file that is used by most menus, and complete it with a nice background image. The directory /tftpboot acts as the root directory of the tftp server, so if in a menu file you see /vesamenu.c32 then in reality this is /tftpboot/vesamenu.c32.

The background image is the file /tftpboot/pxelinux.cfg/kelin4.jpg. (Original from the Slackware Art gallery). The global include menu file is /tftpboot/pxelinux.cfg/default.inc, the contents is:

MENU TITLE Home Server Network Boot Menu
MENU BACKGROUND /pxelinux.cfg/kelin4.jpg

DEFAULT /vesamenu.c32

#MENU MARGIN 0
#MENU ROWS -9
#MENU TABMSG
#MENU TABMSGROW -3
#MENU CMDLINEROW -3
#MENU HELPMSGROW -4
#MENU HELPMSGENDROW -1

#MENU COLOR SCREEN 37;40
#MENU COLOR BORDER 34;40
#MENU COLOR TITLE 1;33;40
#MENU COLOR SCROLLBAR 34;46
#MENU COLOR SEL 30;47
#MENU COLOR UNSEL 36;40
#MENU COLOR CMDMARK 37;40
#MENU COLOR CMDLINE 37;40
#MENU COLOR TABMSG 37;40
#MENU COLOR DISABLED 37;40
#MENU COLOR HELP 32;40

A piece of /tftpboot/pxelinux.cfg/default:

# lx02.mbse.ym network boot menu system.

DEFAULT /vesamenu.c32
MENU INCLUDE /pxelinux.cfg/default.inc
prompt 0

label bootlocal
  menu label ^Boot from default harddisk
  menu default
  KERNEL chain.c32
  APPEND hd0 0

LABEL slackware
  MENU LABEL ^Slackware i486 Installation Menu
  KERNEL /vesamenu.c32
  APPEND /pxelinux.cfg/slackware.conf
  TEXT HELP
  Slackware 32 bits installers.
  ENDTEXT

LABEL archlinux
  MENU LABEL ^Arch Linux Installation menu
  KERNEL vesamenu.c32
  APPEND pxelinux.cfg/arch.cfg
  TEXT HELP
  Arch Linux installers.
  ENDTEXT

LABEL reboot
  MENU LABEL Reboot
  TEXT HELP
  Reboot this client computer
  ENDTEXT
  COM32 reboot.c32

LABEL poweroff
  MENU LABEL Power Off
  TEXT HELP
  Power off this client computer
  ENDTEXT
  COMBOOT poweroff.com

 

Here are the screeshots of a PXE boot:

PXE boot menu

PXE boot menu

 

PXE boot from the network

PXE boot from the network

 

 

 

 

 

 

 

 

Arch Linux installers.

For this we need to download a special CD iso image from the Arch Wiki website. The unpacked contents of this image must be copied to the /tftpboot/arch directory. Then copy /tftpboot/arch/boot/syslinux/syslinux.cfg to /tftpboot/pxelinux.cfg/arch.cfg. Then in this menu change put /arch in front of the paths because the menu was designed to be put in the tftp root, we use the /arch subdirectory. Then we can remove many tools we already have and add a menu entry to our main menu.

I left all menus that I have used in the example package, but without the gigabytes of images. You can find the most actual ones yourself.

 

Download.

The updated configuration.

Linux Home Server complete package
Linux Home Server complete package
homeserver-complete.tar.gz
2.6 MiB
7 Downloads
Details...

Permanent link to this article: http://www.mbse.eu/linux/homeserver/extra/pxeserver/