Setting up a tftp boot environment for Fedora

I already wrote a little article, how to boot a FreeDos via PXE. Of course, you can boot Fedora (or CentOS) in like manner.

0. Setting up the dhcp server

Depending on what actual dhcp server implementation you are using (ISC dhcp etc.) ymwv here anyway. So instead of walking you through this this step-by-step, I suggest you have a look at the sylinux wiki or just ask google.

1. Installing packages

Well, this one is rather easy. Just pull the packages from your yum-repo:

yum install xinetd tftp-server syslinux

2. Configuring xinetd

Enabling xinetd (and tftp) is no big deal:

chkconfig xinetd on
chkconfig tftp on

You may want to find out (or adjust) the tftp root path. Simply edit /etc/xinetd.d/tftp with your favourite editor and change the line that says server_args = -s /tftpboot. Make sure, the service is restarted after you changed something in the configuration file.

3. Setting up boot environment

This is the really beautiful part. Since the initial ramdisk and the kernel is different for every Fedora (even CentOS) release, I wrote a little script to automate this task:

#/bin/bash

  # setupTftpboot
  
  # common source and destination
  CMNSRC=rsync://mirrors3.kernel.org/fedora/releases/12/Fedora/i386/os/isolinux/
  #CMNSRC=rsync://mirrors3.kernel.org/centos/5.4/os/i386/isolinux/
  CMNDST=$1
  PXECFGDIR=pxelinux.cfg
  PXECFGFILE=default
  
  # options
  RSYNCOPTS="-avh --progress --stats --exclude=isolinux.bin"
  
  # syslinux
  SYSLINUXSRC=http://www.kernel.org/pub/linux/utils/boot/syslinux/
  SYSLINUXVER=syslinux-3.86
  
  # files
  WGET=/usr/bin/wget
  MKDIR=/bin/mkdir
  MV=/bin/mv
  RSYNC=/usr/bin/rsync


  function usage() {
        echo "sh $0 <targetdir>"
  }

  if [ -z $CMNDST ]
  then
     usage
     exit 0
  fi
  
  if [ ! -d $CMNDST ]
  then
     echo "Error $CMNDST does not exist"
     exit 0
  fi
  

   $RSYNC $RSYNCOPTS $CMNSRC $CMNDST
  
  if [ ! -d $CMNDST/$PXECFGDIR ]; then $MKDIR -p $CMNDST/$PXECFGDIR; fi
  $MV $CMNDST/isolinux.cfg $CMNDST/$PXECFGDIR/$PXECFGFILE

  $WGET -O - $SYSLINUXSRC/$SYSLINUXVER.tar.gz | tar xvz $SYSLINUXVER/core/pxelinux.0 -O>$CMNDST/pxelinux.0

The usage is quite self-explaining:

sh setupTftpboot <targetdir>

<targetdir> could be /var/lib/tftpboot (on Fedora > 9 (see Bugzilla)) or something like /var/lib/tftpboot/Fedora/12/ for a multi-distribution tftp setup.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.