Monday, March 22, 2010

Remote installation of centos linux using pxe with dhcp tftp and syslinux

Sponsored Links
PXE server helps to install the operating systems through network boot. Its very useful and very time saving.

This post tells how to configure a PXE Server in Redhat linux and other variants.
PXE Configuration

dhcp + tftp + syslinux

Install the packages
#yum -y install dhcp*
#yum -y install tftp*
#yum -y install syslinux*

Open the dhcp configuration file and add the following
[root@sysadmin ~]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#
#

subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers                  192.168.1.1;
        option subnet-mask              255.255.255.0;
        option domain-search              "lukup.internel";
        option domain-name-servers       8.8.8.8;
        option time-offset              -18000;
    range 192.168.1.10 192.168.1.100;
    allow booting;
    allow bootp;
    next-server 192.168.1.254;
    filename "pxelinux.0";
}


Copy the pxlinux.0 file to /tftpboot
#cd /tftpboot
#cp /usr/lib/syslinux/pxelinux.0 .

Copy the kernel and initrd.img files from DVD[/media/images/pxeboot/] to /tftpboot/
#cp -rv /media/images/pxeboot/initrd.img .
#cp -rv /media/images/pxeboot/vmlinuz .

Add kickstart file to /tftpboot/
#vi ks.cfg Only if wanted. Otherwise you have to do attended remote installation.
nfs --server 192.168.1.2 --dir /media/rhel5 Just an example line!

 You need to modify the tftp configuration file under /etc/xinet.d as follows.

[root@sysadmin pxelinux.cfg]# cat /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
#    protocol.  The tftp protocol is often used to boot diskless \
#    workstations, download configuration files to network-aware printers, \
#    and to start the installation process for some operating systems.
service tftp
{
    disable    = no
    socket_type        = dgram
    protocol        = udp
    wait            = yes
    user            = root
    server            = /usr/sbin/in.tftpd
    server_args        = -s /tftpboot
    per_source        = 11
    cps            = 100 2
    flags            = IPv4
}
[root@sysadmin pxelinux.cfg]#

Create PXE configuration directory
#mkdir /tftpboot/pxelinux.cfg/
#cd /tftpboot/pxelinux.cfg/

Create PXE configuration file### That is ###/tftpboot/pxelinux.cfg/default file
#vi default
PROMPT 1 To give the prompt [boot: ]. Otherwise it will automatically install the default label
DISPLAY boot.msg It shows the 1st window for options.
TIMEOUT 100 Wait for the choice this much time and after that will continue with deafult.
DEFAULT main Defines the main installation method. The default one.
ONERROR LOCALBOOT 0

LABEL main The declaration of main label. In case if we didint give choice, this will execute.
KERNEL vmlinuz If in /tftpboot/ directory. If it is in /tftpboot/RHEL5-NFS u've to give RHEL5-NFS/vmlinuz
APPEND initrd=initrd.img Path of initrd.img.
LABEL 1
KERNEL Kernel location of choice 1 in boot.msg
APPEND Location of initrd.img

An Example
kernel RHEL5-NFS/vmlinuz
append initrd=RHEL5-NFS/initrd.img ramdisk_size=6457 method=nfs:192.168.1.2:/media/rhel5 ip=dhcp
LABEL 2
settings for option 2.
:wq

###Creating options message for the PXE boot###
#cd /tftpboot/
#vi boot.msg
##########################
Installing RHEL5 You can design this as you like.
##########################

1. RHEL5 NFS
2. RHEL5 FTP Set all these according to the entries in /tftpboot/pxelinux.cfg/default
3. RHEL5 HTTP
4. RHEL5 RESCUE

##########################

NOTE: Give execute permission for all files in /tftpboot/

###Restart the services###
#service dhcpd start
#service xinetd start
#chkconfig tftp on

Another example is:
[root@sysadmin pxelinux.cfg]# cat default
DISPLAY boot.msg
PROMPT 1
TIMEOUT 100
DEFAULT main
ONERROR LOCALBOOT 0

LABEL main
kernel vmlinuz
APPEND initrd=initrd.img network ks=nfs:192.168.1.254:/media/kick/ks.cfg

LABEL 1
kernel vmlinuz
APPEND initrd=initrd.img network ks=nfs:192.168.1.254:/media/kick/ks.cfg


Useful links
http://www.linuxhelp.in/2012/02/remote-installation-of-centos-linux.html
http://www.linuxhelp.in/2012/02/lets-see-how-to-install-configure-dhcp.html
http://docs.fedoraproject.org/install-guide/f7/en_US/ap-pxe-server.html
http://syslinux.zytor.com/wiki/index.php/PXELINUX
Sponsored Links

No comments:

Post a Comment

Be nice. That's all.