Saturday 30 August 2014

​YUM configurations & Installations using PXE boot with kick-start over FTP - #Redhat 7/CentOS 7

​CentOS 7 has been released on last month (7 July 2014), and there wasn't much help for the network installation(PXE) when I searched in Google.
Hence I had decided to BLOG on the same. This could be helpful for few who are looking on it, you could share in-case if it was helpful.

PXE installations requires the package repository, hence I would let you know on configuring the local YUM repository as well.

​​​Environment: CentOS 7(x86_64)
​​Kernel version: 3.10.0-123.el7.x86_64
​​
​Configure YUM repository:

Mount your DVD and copy all contents to the folder in FTP home directory, and point your repository file to the folder containing the packages.
#mkdir /var/ftp/centos7_x86_64
​#rsync -azvf /media/centos7/* ​ /var/ftp/centos7_x86_64
​#cat /et​c/yum.repos.d/centos7
[centos7]
name=centos7
baseurl=file:///var/ftp/centos7_x86_64
enabled=1
gpgcheck=1

#yum clean all
#yum list all
#yum grouplist

Make sure the below packages are installed, skipping the package installations.

1. tftp-server
2. dhcp
3. vsftpd​​

Configure TFTP:

# cat /etc/xinetd.d/tftp
server_args = -s /var/ftp/tftpboot
disable = no

#mkdir /var/ftp/tftpboot
#mkdir /var/ftp/tftpboot/pxelinux.cfg
#mkdir /var/ftp/tftpboot/centos7_x86_64

#cp /usr/share/syslinux/pxelinux.0 /var/ftp/tftpboot
#cp /usr/share/syslinux/menu.c32 /var/ftp/tftpboot
#cp /usr/share/syslinux/memdisk /var/ftp/tftpboot
#cp /usr/share/syslinux/mboot.c32 /var/ftp/tftpboot
#cp /usr/share/syslinux/chain.c32 /var/ftp/tftpboot
#cp /var/ftp/centos7_x86_64/images/pxeboot/vmlinuz /var/ftp/tftpboot/centos7_x86_64
#cp /var/ftp/centos7_x86_64/images/pxeboot/initrd.img  /var/ftp/tftpboot/centos7_x86_64

Configure DHCP:

# cat /etc/dhcp/dhcpd.conf
option domain-name      "localhost.localdomain";
option domain-name-servers      localhost.com;
default-lease-time 600;
max-lease-time 7200;
authoritative;
#################The followings are mandatory to boot from PXE ###################
allow booting;
allow bootp;
option option-128 code 128 = string;
option option-129 code 129 = text;
next-server 192.168.156.130;
filename "/pxelinux.0";
################################################
subnet 192.168.156.0 netmask 255.255.255.0 
{
range dynamic-bootp 192.168.156.131 192.168.156.140;
option broadcast-address 192.168.156.255;
option routers 192.168.156.1;
}

RHEL offers a graphical tool for creating and editing kickstart files called, Kickstart Configurator (the system-config-kickstart package) which is available in RHEL 7.

When creating or customizing your kickstart file, it is useful to verify that it is valid before attempting to use it in an installation. Red Hat Enterprise Linux 7 includes the ksvalidator command line utility which can be used to do this. This tool is a part of the pykickstart package

# yum install pykickstart

After installing the package, you can validate a Kickstart file using the following command:
#ksvalidator /path/to/kickstart.ks

Kisckstart file was created and could be download here

Configurations PXE:

Note:


On AMD64 and Intel 64 systems with BIOS, the file name can be either default or based on your system's IP address. In this case, add the inst.ks= option to the append line in the installation entry.
APPEND initrd=centos7_x86_64/initrd.img inst.ks=ftp://192.168.156.130/centos7_x86_64/kickstart/ks.cfg

On AMD64 and Intel 64 systems with UEFI, the file name will be grub.cfg. In this file, append the inst.ks= option to the kernel line in the installation entry.
KERNEL centos7_x86_64/vmlinuz inst.ks=ftp://192.168.156.130/centos7_x86_64/kickstart/ks.cfg

# cat /var/ftp/tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 30

MENU TITLE PXE Menu

LABEL centos7_x86_64
    MENU LABEL centos7_x86_64
    KERNEL centos7_x86_64/vmlinuz inst.ks=ftp://192.168.156.130/centos7_x86_64/kickstart/ks.cfg
    APPEND initrd=centos7_x86_64/initrd.img

This completes all your configuration, before this works make sure all your services are running and persistant.

# systemctl start dhcpd
# systemctl start xinetd
# systemctl start vsftpd

# systemctl enable dhcpd
# systemctl enable xinetd
# systemctl enable vsftpd

Make sure your client is booting from the network as the first boot device.