CentOS / RHEL 7 : How to install remote Diskless Client PXE Booting

Boot your client computer which has no local hard drive from PXE server Network booting. Remote diskless system booting requires both a tftp service (provided by tftp-server) and a DHCP service (provided by dhcp). The tftp service is used to retrieve kernel image and initrd over the network via the PXE loader and dhcp service is provided dynamic ip to client system.

STEP:-1 -> first disable Selinux status and firewalld services.

[root@classroom tftpboot]# systemctl stop firewalld
[root@classroom tftpboot]# systemctl disable firewalld
[root@classroom tftpboot]# vim /etc/sysconfig/selinux
SELINUX=disabled
After that rebbot the system for this changes apply.

STEP:-2 -> To set up a basic remote diskless system booted over PXE, you need the following packages:-

 tftp-server
 xinetd
 dhcp
 syslinux
 dracut-network
 nfs-utils
[root@classroom Desktop]# yum install dracut-network tftp-server Xined dhcp* syslinux -y
 install Dracut-network packages then add the following line to /etc/Dracut.conf file
 [root@classroom Desktop]# vim /etc/dracut.conf
add_dracutmodules+="nfs"
[root@classroom Desktop]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@classroom Desktop]# mkdir /var/lib/tftpboot/rhel7
[root@classroom Desktop]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

STEP:-3 -> Configuring and Start xinetd services:-

[root@classroom tftpboot]# vim /etc/xinetd.d/tftp
# line 14: change
disable =no
[root@classroom tftpboot]# systemctl start xinetd
[root@classroom tftpboot]# systemctl enable xinetd

STEP:- 4-> DHCP SERVER Configuration FOR DISKLESS CLIENTS

Configure the DHCP server, below mentioned configuration we have to modify in dhcp configuration file.
[root@classroom]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp: overwrite ‘/etc/dhcp/dhcpd.conf’? y
[root@classroom tftpboot]# vim /etc/dhcp/dhcpd.conf
# Add below lines to starting
allow booting;
allow bootp;
authoritative;
# option definitions common to all supported networks...
option domain-name "example.com";
option domain-name-servers 192.168.72.10;
filename "pxelinux.0";
next-server 192.168.72.10;
# A slightly different configuration for an internal subnet.
subnet 192.168.72.0 netmask 255.255.255.0 {
range 192.168.72.10 192.168.72.254;
option routers 192.168.72.10;
option broadcast-address 192.168.72.255;
# Fixed IP addresses can also be specified for hosts. These addresses
# should not also be listed as being available for dynamic assignment.
# Hosts for which fixed IP addresses have been specified can boot using
# BOOTP or DHCP. Hosts for which no fixed address is specified can only
# be booted with DHCP, unless there is an address range on the subnet.
host client1 {
option host-name "client1.example.com";
hardware ethernet 00:0C:29:97:AF:32;
fixed-address 192.168.72.13;
}
host client2 {
option host-name "client2.example.com";
hardware ethernet 00:0C:29:64:2D:C8;
fixed-address 192.168.72.25;
}
[root@classroom tftpboot]# systemctl restart dhcpd
[root@classroom tftpboot]# systemctl enable dhcpd
[root@classroom tftpboot]# systemctl stuas dhcpd

STEP:-5 -> CONFIGURING A TFTP SERVICE FOR DISKLESS CLIENTS

[root@classroom pxeboot]# cp /var/ftp/pub/rhel7/images/pxeboot/vmlinuz /var/lib/tftpboot/rhel7/
[root@classroom pxeboot]# cp /var/ftp/pub/rhel7/images/pxeboot/initrd.img /var/lib/tftpboot/rhel7/
[root@classroom root]# mkdir -p /var/lib/tftpboot/rhel7/root
[root@classroom root]# yum groups install "Server with GUI" --releasever=7 --installroot=/var/lib/tftpboot/rhel7/root/
[root@classroom rhel7]# cd /var/lib/tftpboot/rhel7/
[root@classroom rhel7]# ls -ll
-r--r--r-- 1 root root 36646096 Jan 15 18:27 initrd.img
dr-xr-xr-x 17 root root 4096 Jan 15 19:06 root
-r-xr-xr-x 1 root root 5026624 Jan 15 18:27 vmlinuz

STEP:- 6 -> generate encrypted root password

[root@classroom rhel7]# python -c 'import crypt,getpass; \ print(crypt.crypt(getpass.getpass(), \ crypt.mksalt(crypt.METHOD_SHA512)))'
Password: $6$EC1T.oKN5f3seb20$y1WlMQ7Ih424OwOn.....
[root@classroom rhel7]# cat /var/lib/tftpboot/rhel7/root/etc/shadow
root:$6$1/fjRPUrvL8cl9t2$axgNxg6FzYUkz0Fqr1wTRP73YX3z9mnDNhhk2wjtTIUZ1ZkzhFCDKZsi675LpTQ551rzddFG/oPb5EeoCAz6K0:16297:0:99999:7:::

STEP:-7 -> CONFIGURING AN EXPORTED FILE SYSTEM FOR DISKLESS CLIENTS

[root@classroom rhel7]# vim /var/lib/tftpboot/rhel7/root/etc/fstab
none /tmp tmpfs defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
[root@classroom rhel7]# vim /var/lib/tftpboot/pxelinux.cfg/default
default rhel7
label rhel7
kernel rhel7/vmlinuz
append initrd=rhel7/initrd.img root=nfs:192.168.72.10:/var/lib/tftpboot/rhel7/root rw selinux=0

STEP:-8 -> Configure NFS server to share File system with clients

[root@classroom rhel7]# vim /etc/exports
/var/lib/tftpboot/rhel7/root 192.168.72.0/24(rw,no_root_squash,async)
[root@classroom rhel7]# exportfs -avr
[root@classroom rhel7]# showmount -e
Export list for classroom.example.com:
/var/lib/tftpboot/rhel7/root 192.168.72.0/24
[root@classroom rhel7]# systemctl start rpcbind
[root@classroom rhel7]# systemctl enable rpcbind
[root@classroom rhel7]# systemctl start nfs
[root@classroom rhel7]# systemctl start nfs-server
[root@classroom rhel7]# systemctl enable nfs-server

Create new VM in vmware with No ISO path and note down mac address of PXE client and bind mac address into dhcp server configuration file with static IP and restart dhcp services
Before booting the client system we have to need set the host only configuration into VMware->virtual network editor settings.








These clients can boot over the network via PXE through NFS services.

No comments:

Post a Comment

T he primary difference is that  Linux  and  Unix  are two different Operating Systems though they both have some common commands. Let...