Sunday, December 16, 2012

Creating a PXE Server with Scientific Linux 6 step by step

yum install nano dhcp tftp-server httpd syslinux ftp

Disable the firewall

 nano /etc/sysconfig/selinux

change the line to

SELINUX=disabled

save the file

nano /etc/xinetd.d/tftp

disable=no

save the file

service restart xinetd

cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot
cp /usr/share/syslinux/memdisk /var/lib/tftpboot
cp /usr/share/syslinux/mboot.c32 /var/lib/tftpboot
cp /usr/share/syslinux/chain.c32 /var/lib/tftpboot


Create the directory for your PXE menus

mkdir /var/lib/tftpboot/pxelinux.cfg

mkdir /var/lib/tftpboot/images

mkdir /data

mount -ro loop /media/centos.iso /data


create /etc/dhcp/dhcpd.conf


#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;

option option-128 code 128 = string;
option option-129 code 129 = text;


set vendorclass=option vendor-class-identifier;

subnet 192.168.163.0 netmask 255.255.255.0 {

option routers 192.168.163.2;
option domain-name-servers 192.168.163.2;
option subnet-mask 255.255.255.0;
range 192.168.163.100 192.168.163.105;
filename "/pxelinux.0";
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.163.25;
}

service dhcpd restart

copy the pxeboot folder in images folder in the Centos dvd

cp -rv pxeboot/* /var/lib/tftpboot/images/

cd /var/lib/tftpboot/pxelinux.cfg

create a file named default

nano default

#this file should contain this


default menu.c32
prompt 0
timeout 300
ONTIMEOUT local

MENU TITLE PXE Menu


LABEL CentOS 5 PXEBOOT
       MENU LABEL CentOS 5 
        KERNEL images/vmlinuz
        APPEND initrd=images/initrd.img ramdisk_size=100000 ksdevice=eth1 ip=dhcp


#save the file


service start httpd

mkdir /var/www/html/install

mount the cent os DVD in the install folder

service httpd restart

Now the client should boot and get an ip from the pxe server and start booting

Wait this process is troublesome and I have faced several errors

First I faced the PXE-E32: TFTP open timeout error

Then I faced PXE- T01 File not found error because my tftpboot was in / instead of in /var/lib/tftpboot

at first the client is not even able to find the boot files

The reason was I first created the tftpboot directory in the /,which didn't work for me

so I moved the tftpboot folder in the /var/lib/tftpboot like this path is mentioned in /etc/xinetd.d/tftp file

then I faced the infamous "permission denied" error,the error is actually like this

pxe t00 permission denied

Now I don't know much about security,but I found this solution in his page

http://unix.stackexchange.com/questions/31809/permission-denied-trying-to-get-a-file-using-tftp


The solution is like this
   

"Probably a selinux problem. Do a ls -alZ in the directory. On RHEL5/Centos5 the context should be user_u:object_r:tftpdir_t.

You can run restorecon -Rv /tftproot to fix it.

Edit: Just saw the fedora tag. It seems you're using not F16 but an earlier version, so the instructions above should work for you. With F16 the tftproot is in /var/lib and the context is system_u:object_r:tftpdir_rw_t:s0."

So I used this command and finally felt sane again as the pxe server worked finally.

restorecon -Rv /var/lib/tftpboot/


Now I am ready to sleep,it's 4.50 in the morning.


Sourav Bhattacharya

Linux Faculty for 7 years

No comments:

Post a Comment