pxe-nfs

The Preboot eXecution Environment (PXE) is an environment to boot computers using a network interface independently of data storage devices (like hard disks) or installed operating systems.

Trivial File Transfer Protocol (TFTP) is a file transfer protocal notable for its simplicity. It is generally used for automated transfer of configuration or boot files between machines in a local environment. Compared to FTP, TFTP is extremely limited, providing no authentication, and is rarely used interactively by a user.
Due to its simple design, TFTP could be implemented using a very small amount of memory. It is therefore useful for booting computers such as routers which may not have any data storage devices. It is an element of the Preboot Execution Environment (PXE) network boot protocol, where it is implemented in the firmware ROM / NVRAM of the host’s network card.

The initial stages of some network based installation systems such as Solaris Jumpstart, Red Hat Kickstart Installation Services use TFTP to load a basic kernel that performs the actual installation

#yum install dhcp*

Modify the /etc/dhcpd.conf as shown below

#vi /etc/dhcp/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
allow booting;
allow bootp;
authoritative;
# IP address of the dhcp server nothing but this machine.
subnet 192.168.31.0 netmask 255.255.255.0 {
range 192.168.31.102 192.168.31.120;
next-server 192.168.31.100;
filename “pxelinux.0”;

Specify the interface in /etc/sysconfig/dhcpd to listen dhcp requests coming from clients.

#vi /etc/sysconfig/dhcpd
DHCPD_INTERFACE=”eth0”;
Here, this machine has the ip address of 192.168.31.101 on the eth0 device. So, specify eth1 for the DHCPD_INTERFACE as shown above.

2

#yum install syslinux tftp-server

Modify /etc/xinetd.d/tftp
Modify the /etc/xinetd.d/tftp file to reflect the following. By default the value for disable parameter is “yes”, please make sure you modify it to “no” and you need to change the server_args entry to -s /tftpboot.

# vi /etc/xinetd.d/tftp
service tftp {
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftp
server_args = -s /tftpboot
disable = no
}

No changes in /etc/xinetd.conf
There is no need to modify the etc/xinetd.conf file. Use the default values specified in the xinetd.conf file.
Restart xinetd, dhcpd services
Restart these services as shown below.

# /etc/init.d/xinetd restart
# /etc/init.d/dhcpd restart
#chkconfig dhcpd on
#chkconfig xinetd on

4

#cd /var/lib/tftpboot
#mkdir centos62
#cd centos62

Mount the iso image in media directory
Copy the initrd.img and vmlinuz in the centos62 directory

#cp /media/isolinux/initrd.img .
#cp /media/isolinux/vmlinuz .
#cd /var/lib/tftpboot
#cp /usr/share/syslinux/pxelinux.0 .
#mkdir pxelinux.cfg
#cd pxelinux.cfg/

Create a empty file named with default
#vi default
UI menu.c32
MENU TIMEOUTROW 20
DEFAULT Harddisk
LABEL centos62
MENU LABEL ^CentOS 6.2
KERNEL centos62/vmlinuz
APPEND initrd=centos62/initrd.img
LABEL Harddisk
MENU LABEL ^Hard Disk
LOCALBOOT 0x80

#cp /usr/share/syslinux/menu.c32 .
#chmod 755 /var/lib/tftpboot/*

#chown nobody:nobody /var/lib/tftpboot/*
# restorecon -RF /var/lib/tftpboot/*

5

6

#iptables -I INPUT -p udp –dport 69 -j ACCEPT
#service iptables save
#service iptables restart

6z

Now we have setup the installation method

#yum install vsftpd nfs

We already mount the centos CD in media directory
#cp –rf /media/* /var/ftp/pub

#service vsftpd restart

#vi /etc/exports
/var/ftp/pub 192.168.31.0/24(rw,sync)

#exportfs -a
#service nfs restart
#chkconfig nfs on
#chkconfig vsftpd on
#showmount -e

We can use the installation method either FTP or NFS.

Finally, the tftpboot setup is ready and the client machine can be booted after changing the first boot device as “network” in the BIOS settings.

If you encounter any tftp error, you can do the troubleshooting by retrieving some files through tftpd service.
Retrieve some file from the tftpserver to make sure tftp service is working properly using the tftp client. Let us that assume that sample.txt file is present under /tftpboot directory.

# tftp -v 192.168.31.100 -c get sample.txt

7

8

9

10

11

12

13

14