Tuesday, April 5, 2011

Creating a PXE boot kickstart server Centos

Packages required: tftp, dhcp & syslinux

1. Install the required packages on the server. Syslinux is usually by default installed on the server.

#yum install tftp-server dhcp syslinux

2. Edit /etc/xinet.d/tftp file to run the tftp service under xinetd daemon. Modify the following lines in the conf file as follows:

disable                 = no
server_args             = -s /tftpboot

Make sure the both the lines should be exactly like this, because we are going to use the /tftpboot dir as default root-pxe dir. If the path given here in server-args is different from our pxe root dir, then we'll normally get "PXE-T01: File not found." error. Save the above file after making the changes.

3. Restart the xinetd services to start the tftp service and make it executable on startup.

#service xinetd start
#chkconfig xinetd on

4. Copy the required files from the Syslinux dir to /tftpboot dir.

#cp /usr/lib/syslinux/{pxelinux.0,menu.c32,mboot.c32,memdisk,chain.c32} /tftpboot/

5. Create PXE Menu directory.

# mkdir /tftpboot/pxelinux.cfg

6. Create dir for centos image in tftpboot dir. Suppose you  have centos 5.5 i386 and centos 5.5 x86_64 linux iamges, then create dir as follows.

# mkdir -p /tftpboot/images/centos/i386/5.5
# mkdir -p /tftpboot/images/centos/x86_64/5.5

7. mount the linux iso image that you have to /mnt and copy initrd.img and vmlinuz files from the /mnt/images/pxeboot dir to the respective tftpboot image paths that you have created.

# mount -o loop /home/centos-5.5.i386.iso /mnt
# cp /mnt/images/pxeboot/{ initrd.img, vmlinuz} /tftpboot/images/centos/i386/5.5
# umount /mnt
# mount -o loop /home/centos-5.5.x86_64.iso /mnt
# cp /mnt/images/pxeboot/{ initrd.img, vmlinuz} /tftpboot/images/centos/x86_64/5.5
# umount /mnt

8. Edit dhcpd.conf file and add the following lines to the configuration. Use your pxe server ip in place of the

allow bootp;
allow booting;
filename "pxelinux.0";
option option-128 code 128 = string;
option option-129 code 129 = text;

9. Create a file /tftpboot/pxelinux.cfg/default for default menu and add the following.

default menu.c32
prompt 0
timeout 300


LABEL Centos 5.5 x86
          MENU LABEL Centos 5.5 x86
          KERNEL images/centos/i386/5.5/vmlinuz
          APPEND ks initrd=image/centos/i386/5.5/initrd.img ramdisk_size=100000 ksdevice=eth0 ip=dhcp url --url http://path to ks file

 LABEL Centos 5.5 x86_64
          MENU LABEL Centos 5.5 x86_64
          KERNEL images/centos/x86_64/5.5/vmlinuz
          APPEND ks initrd=image/centos/x86_64/5.5/initrd.img ramdisk_size=100000 ksdevice=eth0 ip=dhcp url --url http://path to ks file

10.  Restart the dhcpd server and restart the xinetd service.

#service dhcpd restart
#service xinetd restart

You can add more images to your pxe configuration later on in the similar way. 

No comments: