How-to : Basic PXE infrastructure #3 – TFTP server installation and setup on CentOS

pxe

Introduction

This is the third post from the How-to build a basic PXE infrastructure series, in which we are going to setup the TFTP server.

TFTP server role is to provide the client with the files for the installation, such as Network Bootstrap Program (NBP) which is loaded in client RAM, and the usual Linux boot files (vmlinuz and other initrd) from the selected distribution (automatically selected or selected via a pxe menu, we’ll see how to do that later).

The goal of this series is, again, to setup a minimalist working PXE infrastructure, we will see an advanced setup that uses kickstart and complex automated installation later, let’s start by the beginning !

 

 

The other post from this series

 

 

1) Installing the tftp server and required packages

Easy.

1.1 Preamble

As you can see in the following section, there are 2 ways of installing the basics tftp (in PXE context) server packages, either you :

  1. Install only the basic tftp-server package : Choosing this option you will have to retrieve the required files from the web and create required directories  by yourself, as well as setting up the correct permissions etc.
  2. Install the tftp-server & the syslinux-tftpboot package : This includes anything you would need to make your tftp server work for a PXE client.

 

1.2 tftp-server base package

yum install tftp-server

Which also install xinetd (if not yet installed) as a dependency.

 

1.3 Additional tftp package

I do choose to install the syslinux-tftpboot package for convenience reasons, in case you do not want or cannot do that you will have to built the directories and files tree by yourself.

The syslinux-tftpboot package may be installed using yum command on Fedora Based (CentOS, RHel an Fedora) as :

yum install syslinux-tftpboot

This will create and populate the /tftpboot directory with good permissions and so on as :

[root@CentOS-62_PXE-BASE tftpboot]# ls -ld /tftpboot/
drwxr-xr-x. 3 root root 4096 Apr 30 23:26 /tftpboot/
[root@CentOS-62_PXE-BASE tftpboot]# ls /tftpboot/                                                   
cat.c32     cpuidtest.c32  gfxboot.c32  ifcpu64.c32  linux.c32  memdump.com  poweroff.com  reboot.c32   vesainfo.c32
chain.c32   disk.c32       gpxecmd.c32  ifcpu.c32    ls.c32     meminfo.c32  pwd.c32       rosh.c32     vesamenu.c32
cmd.c32     dmitest.c32    gpxelinux.0  ifplop.c32   lua.c32    menu.c32     pxechain.com  sanboot.c32  vpdtest.c32
config.c32  elf.c32        hdt.c32      int18.com    mboot.c32  pcitest.c32  pxelinux.0    sdi.c32      whichsys.c32
cpuid.c32   ethersel.c32   host.c32     kbdmap.c32   memdisk    pmload.c32   pxelinux.cfg  sysdump.c32

This is a lot of files ! We are not going to use them all, let’s just make everything to work first.

 

1.4 tftpboot directory / files explained

Here is a quick information about what those files are, and what they are used for.

As we can see there are different file extensions.

You should know that file extensions are usually not used by a Linux system, but SYSLINUX DOES ! (due to a lack of reliable magic numbers within Linux kernel boot sector images and COMBOOT files).

The following is a list of file extension and their use :

  1. none or other extensions
    Linux kernel image : image file that contains Linux kernel image (often compressed)
    e.g : vmlinuz or memdisk
  2. .0
    PXE bootstrap program (NBP) : This file (served by the TFTP server ) is responsible for the 2nd stage boot by locating and loading the required files from the tftp server.
    Boot Strap program purpose is to find and load a bootable operating system, this is for example what we can find in a Hdd MBR.
    e.g : The pxelinux.0 file, is responsible for locating and loading the operating system (vmlinuz).
  3. .com or .c32
    These are binary COMBOOT files (runnable from DOS), 16bit (.com) or 32bit (c32). They are used in first stage of the PXE boot, for thing such as menu displaying.

Also, the pxelinux.cfg directory is where the PXE client configuration files are stored.

 

 

2) Setting up the tftp server

There is a bit more to be done here.

We first need a tftp base directory (already done if you installed the syslinux-tftpboot package), that contains every single files required by the initial loading process. This directory contains the pxelinux.o file and the pxelinux.cfg.

Please note that the tftp server daemon is actually managed by the xinet (eXtended InterNET Services) daemon, therefore the tftp server configuration file is located under /etc/xinetd.d/tftp. This configuration file is easy to understand and there is not much to do about it, there is actually 2 parameters that needs changes :

  1. disable = yes changed to
    disable = no
    No need to explain this…
  2. server_args = -s /var/lib/tftpboot changed to
    server_args = -vvs /tftpboot
    This is the path to the tftpboot directory we also add the verbose flag to get more info (can be removed whenever the setup is confirmed)

Do not forget to restart (or reload) the xinet daemon to apply changes :

service xinetd reload

See the above excerpt for a working tftp configuration file example :

# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        # The following line specifies the directory containing pxelinux.0 file, 
        # thus this must be edited, as its default is /var/lib/tftpboot, and we want to use /tftpboot.
        # Also, we add the double verbose flags to understand / see what is going on
        server_args             = -vvs /tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

From my personal experience there is no need to edit the /etc/xinetd.conf file.

Once you did this 2/3 steps you may have a working tftp server to use for your XPE client.

 

3) FAQ

3.1 The TFTP error 1 / file not found / unable to load file error

Loading <some_IP_address>:/path/to/pxelinux.0 .TFTP error 1 (file not found)
Unable to load file

You might need to double check the different paths, defined in your tftp server AND within your dhcpd.conf file.

e.g : The pxelinux.0 is /tftpboot/pxelinux.0, then you should have something like (or equivalent)

  • server_args in tftp configuration file (/etc/xinetd.d/tftp) :
    server_args = -s /tftpboot
  • filename definition in dhcpd configuration file (/etc/dhcp/dhcpd.conf or the include file if any) :
    filename "pxelinux.0";

As you can see, the full path to the pxelinux.0 is built against the tftp server server_args parameter. So for the above configuration the full path would actually be :

$server_args/pxelinux.0 = /tftpboot/pxelinux.0

 

3.2 The TFTP prefix / Unable to locate configuration file error

TFTP prefix :
[...]
Unable to locate configuration file

 

The system is looking for the configuration file. This file can be named after multiples patterns (e.g : 01-88-99-aa-bb-cc-dd or C000025B and finally default) these possibles filenames should be displayed where i put the square brackets “[...]” in the above code excerpt, and if none of those files are found you will get this error.

So the problem with your configuration file could be :

  • It is not where it should :
    Usually under /tftpboot/pxelinux.cfg/. As said here “Note that all filename references are relative to the directory pxelinux.0 lives in”
  • It is not valid :
    Check your config file syntax (try to replace your file by the one provided by the syslinux package)  and config file naming scheme.
  • You have a permissions issue :
    The tftpboot directory should be 755 owned by root and the files within should be 664
  • You have SELINUX enabled and/or a firewall blocking access to the file(s) (<—)
    You might want to disable your firewall and SELINUX to ensure this is not the cause.
    Disable SELINUX by updadting its config file (/etc/SELINUX/config) as : SELINUX=disabled
    Disable firewall by issuing :

    service iptables stop

 

 

4) Conclusion

You may now have a working tftp server, so let’s jump to the next step : nfs server.

 

Resources

 

 

BONUS : PXE process screen-shots

At this point of the setup you should have some kind of a working PXE installation infrastructure, there is still a lot of possible improvement because now you have to specify every single parameter of the installation process manually, but it is working. Here is the kind of stuff you may face :

Lan booting

This is an example of VirtualBox boot menu, i here choose the “l” option to boot on lan.

Dhcp Discover

Dhcp Offer + Request + Ack + pxelinux.0 file loading

As you can see here, dhcp protocol allow you to transmit information (such as Gateway ip address)…

PXE Menu and Linux kernel start loading

This is the menu generated by the /tftpboot/pxelinux.cfg/default file, we will see later how to customize this menu as it offers quite a lot of possibilities. You can also see at the bottom that the choice have been made and the client is loading initial files…

The manual installation process start

This is where the process should be improved to avoid any human intervention…

Installation media menu

This where we understand we miss something, such as an NFS server to serve the installation file, jump here to finalize the basic PXE infrastructure setup…

 

 

More “How-to” posts

4 thoughts on “How-to : Basic PXE infrastructure #3 – TFTP server installation and setup on CentOS

  1. core-basic

    I’m sure we could trade knowledge even. You seem to know a lot more network wise, and I may know more web programming wise. I’m currently a student on my way to hopefully being a network admin.

    1. Pier Post author

      Yes sure, feel free to ask if you have any question related to any post.
      I started yesterday studying (@ home) html and CSS, then i’ll do some PHP (i already know a bit of SQL).
      I am sure we will meet up again on the wordpress forum !
      Wish you the best for your studies.

    1. Pier Post author

      Thank you very much core-basic for your kind comments (both, even if one disappeared!).
      I’ll be happy to check out your site when it will be online, especially as i definitely need to learn web technology (php, html and css).

      Don’t forget to contact me when it’ll be ready.

Leave a Reply to core-basic Cancel reply

Your email address will not be published. Required fields are marked *

This site supports SyntaxHighlighter via WP SyntaxHighlighter. It can highlight your code.
How to highlight your code: Paste your code in the comment form, select it and then click the language link button below. This will wrap your code in a <pre> tag and format it when submitted.