Flag This Hub

How to Configure PXE Server on Linux

By


How to Configure PXE Server on Linux

This is a detailed step by step procedure to set up a PXE (Preboot Execution Environment). A PXE install server allows client machines to boot and install a Linux distribution over the network. This is really handy if your client computers don't have any CD or DVD drives, or if you want to set up multiple computers at the same time (e.g. in a large enterprise), or simply because you want to save time and money both.

To make this setup work , you would need following components:

1. DHCP Server

2. TFTP Server

3. NFS/FTP/HTTPD server (to store and share installing files)

Step 1: Configuring DHCP Server

Assuming that you know how to configure DHCP server, you would need to add the following lines to your existing DHCP server configuration. If you are not familiar with it then you can read the DHCP configuration document here.

 
allow booting
allow bootp
next-server 192.168.0.254;
filename "pxelinux.0";
 
 
 
 


Step 2: TFTP Server Configuration


Assuming that you have your YUM repository configured for your RHEL/Fedora/CENTOS distribution, you would need to run the following command to install the tftp server package

# yum install tftp-server

Now edit /etc/xinetd.d/tftp and it should look something like this.

service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

Step 3: Creating the Network Installation Source


We can use three methods to share installation files on the network and retrieve it when booting the client using pxe. We can use nfs, ftp or http. We would be considering ftp in this document for example. To install ftp server:

# yum install vsftpd

# chkconfig vsftpd on

# service vsftpd start

Public accessible ftp site is located in /var/ftp. create installation tree in this folder.

# mkdir –p /var/ftp/pub/centos/i386/5.4

If you have download dvd or cd iso files, you can mount it and copy the installation files, to mount an iso file:

# mount –t iso9660 –o loop CentOS-5.4-i386-bin-DVD.iso /mnt

once mounted the ISO file copy the installation files to /var/ftp/pub/centos/i386/5.4.

You would need to do this for each Linux distribution you want to include in your PXE server.

# cp –avr /mnt/* /var/ftp/pub/centos/i386/5.4

Restart the services vsftpd, xinetd and dhcpd.

Step 4: Setup TFTP network boot files

Create /tftpboot/images/ directory and copy the files necessary to start the installation program via PXE.

1. Copy the /usr/lib/syslinux/pxelinux.0 file installed by the syslinux package into /tftpboot/

# cp /usr/lib/syslinux/pxelinux.0 /tftpboot.

2. Create /tftpboot/images/ directory tree and copy vmlinuz and initrd files from first cd/dvd or install-souce (/images/pxeboot/vmlinuz and /images/pxeboot/initrd).

# mkdir –p images/centos/i386/5.4

# cp /var/ftp/pub/centos/i386/5.4/images/pxeboot/vmlinuz /tftpboot/images/centos/i386/5.4/

# cp /var/ftp/pub/centos/i386/5.4/images/pxeboot/initrd /tftpboot/images/centos/i386/5.4/

Step 5: Create PXE Menu

Use the following steps to configure PXE menu.

1. Copy menu.c32 file from /usr/lib/syslinux/menu.c32 into /tftpboot

# cp /usr/lib/syslinux/menu.c32 /tftpboot

2. Create /tftpboot/pxelinux.cnf directory

# mkdir /tftpboot/pxelinux.cnf

3. Create /tftpboot/pxelinux.cnf/default configuration file. Following is my default file configuration.



default menu.c32
prompt 0
timeout 300

MENU TITLE PXE Menu

LABEL CentoS 5.4 i386
MENU LABEL CentOS 5.4 i386
KERNEL images/centos/i386/5.4/vmlinuz
append vga=normal initrd=images/centos/i386/5.4/initrd.img ramdisk_size=32768 method=ftp://192.168.0.254/pub/centos/i386/5.4

LABEL RHEL i386
MENU LABEL RHEL i386
KERNEL images/rhel/i386/6/vmlinuz
append vga=normal initrd=images/rhel/i386/6/initrd.gz ramdisk_size=32768 method=ftp://192.168.0.254/pub/rhel/i386/6

If you have a kickstart file for automated installation add the following lines to the menu.

Edit /ftpboot/pxelinux.cfg/default file and add ks parameter.


LABEL CentoS 5.4 i386 Autoinstall
MENU LABEL CentOS 5.4 i386 Autoinstall
KERNEL images/centos/i386/5.4/vmlinuz
append vga=normal initrd=images/centos/i386/5.4/initrd.img ramdisk_size=32768 ks=ftp://192.168.0.254/pub/ks/ks.cfg

Now when you boot the client machines in the network, using network boot option, they should show you the boot menu. Select the boot menu and start the installation.

If you face any issues while configuring your PXE Server, please feel free to post your comments or mail me.

Comments

jyothi 3 months ago

hi,

i have configured pxe server using nfs. In the pxelinux.cfg/default file i have added the following line: append initrd=rhel6_64/initrd.img method=nfs:200.168.1.65:/work/RHEL6

If i try to install OS in the client system it prompts for the OS selection but it is not installing. could you kindly help me to solve this problem

Submit a Comment
Members and Guests

Sign in or sign up and post using a hubpages account.



    Like this Hub?
    Please wait working