PXE-Boot and Kickstart

Description: PXE (Pre-boot Execution Environment): it is used to install a system on a client over network which doesnot have DVD/CD-ROM, the client gets booted only using network interface card. This installation requires DHCP server, which provides the client the IP address and network information such as name server. IP address or tftp server , which will provide the necessary files to start the installation program and the location of the files on the tftp server.

Installation steps:
 Configuring HTTP server
 Configure the files on the tftp server
 Configure DHCP
 Start all the services
 Boot the client and start the installation.

1. Install PXE server :
Install the following packages for the pxe installation.
# yum -y install httpd xinetd syslinux tftp-server dhcp*

2. Configure PXE Server:
Mount the centos7 image onto the /mnt/ directory using the following command.
#mount /dev/sr0 /mnt/

3. Create the new directory to store the centos7 packages and then copy the contents of /mnt/ file to /var/www/centos7/.
# mkdir /var/www/centos7
# cp var /mnt/* /var/www/centos7/

# Vi /etc/httpd/conf.d/pxe.conf

4. Create the apache configuration file for pxe server under /etc/httpd/conf.d directory using the command

 

Then , add the following lines in the configuration file.

Directory /var/www/centos7/
Options Indexes FollowSymLinks
Order Deny, Allow
Allow from all
/Directory

5. Then, configure tftp server, by first copying the necessary files to start the tftp server so that they can be available when client requests them.

6. So, first copy all the boot loaders files to /var/lib/tftpboot and then create a new directory under /var/lib/tftpboot named centos7 to copy bootable kernel and initrd images from dvd mounted location to the created directory /var/lib/tftpboot/centos7 using the following commands.

# cp -a /usr/share/syslinux/* /var/lib/tftpboot/
# mkdir /var/lib/tftpboot/centos7
# cp -a /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/centos7/
# cp -a /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/centos7/

7. PXE Server normally reads its configuration from a Default file present in a folder called pxelinux.cfg, create a configuration directory for PXE server using the following command.

# mkdir /var/lib/tftpboot/pxelinux.cfg

Now , create a default configuration file under pxelinux.cfg using the command
# vi /var/lib/tftpboot/pxelinux.cfg/default

Then, add the following lines to it.

prompt 0
timeout 300
ONTIMEOUT 1
menu title ####### CENTOS 7 PXE Boot Menu ########
label 1
menu label ^1) Install CentOS 7
menu default
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=http://192.168.0.46/centos7 devfs=nomount
label 2
menu label ^2) Boot from local drive
localboot 0

8. Then, to enable the tftp service edit the configuration file /etc/xinetd.d/tftp using the command

# vi /etc/xinetd.d/tftp

“disable”= “no” (change disable = yes to no)

9. Then, configure DHCP server by editing the DHCP configuration file /etc/dhcp/dhcpd.conf as
# vi /etc/dhcp/dhcpd.conf

Here, add the following lines

subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.150 192.168.0.200;
option domain-name-servers 8.8.8.8, 8.8.4.4;
option domain-name "unixadmin.in";
option routers 192.168.0.1;
option broadcast-address 192.168.0.255;
default-lease-time 600;
max-lease-time 600;
max-lease-time 7200;
filename "pxelinux.0";
}

10. Start all the services using the following command

#systemctl enable xinetd
#systemctl enable httpd
#systemctl enable dhcpd

Then , boot the client and start the installation.

2. Kickstart :

Description:
The kickstart is a method which is used to perform automatic unattended operating system installation and configuration.
The kickstart installation and configuration steps are shown below:

Steps of installation:

1. Install the following package in order to install the new kickstart configuration file.
# yum –y install system-config-kickstart

2. Then run the following command to configure the kickstart file
# system-config-kickstart

The following window appears after running the above command.Then, in the basic configuration choose required language, keyboard layout, timezone, root password and select reboot system after installation as below.

Then, in installation method select required installation method and installation source.

Next, in boot loader option select the required installation type grub password and install option.

In partition section provide the required partition.

Then, add the required mount points as below:

In network configuration option add the network device which can be either DHCP or static ip.

Then, in firewall configuration disable selinux and firewall as

Then, save the configuration file in the root directory.

3. After creating the (ks.cfg) kickstart configuration file, edit the configuration file by adding the required packages to the package section or copy this section from basic kickstart configuration file (anaconda-ks.cfg) and save it.

4. Then copy the new created kickstart configuration file to the /var/www/centos7 directory created earlier.

5. Then , in /var/lib/tftpboot/pxelinux.cfg/ edit the default configuration and add the following lines

default menu.c32
prompt 0
timeout 300
ONTIMEOUT 1
menu title ####### CENTOS 7 PXE Boot Menu ########
label 1
menu label ^1) Install CentOS 7
menu default
kernel centos7/vmlinuz
# append initrd=centos7/initrd.img method=http://192.168.0.46/centos7 devfs=nomount
append initrd=/centos7/initrd.img inst.repo=http://192.168.0.46/centos7 ks=http://192.168.0.46/centos7/ks.cfg
label 2
menu label ^2) Boot from local drive
localboot 0

Restart the services.
Then, boot the client and the installation gets started as

Be the first to comment on "PXE-Boot and Kickstart"

Leave a comment

Your email address will not be published.


*