Linux basic learning - using PXE+Kickstart unattended installation service

Posted by ILMV on Sun, 05 Jan 2020 08:46:48 +0100

Unattended installation system

PXE(Preboot eXecute Environment) is a technology developed by Intel company. It can let the computer boot the operating system through the network (provided that the network card installed on the computer supports PXE Technology). It is mainly used to guide the client host to install the Linux operating system in the UAV on duty installation system

Host name operating system IP address
Unattended system RHEL7 192.168.56.25
Client host No operating system installed -

Deploy DHCP server

[root@mail ~]# yum install dhcp -y
[root@mail ~]# vim /etc/dhcp/dhcpd.conf 
allow booting;
allow bootp;
ddns-update-style interim;
ignore client-updates;
subnet 192.168.56.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.56.25;
range dynamic-bootp 192.168.56.100 192.168.56.200;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.56.25;
filename "pxelinux.0";
}

Configure TFTP server

[root@mail ~]# yum install tftp-server -y
[root@mail ~]# vim /etc/xinetd.d/tftp 
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no //yesChange tono
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

[root@mail ~]# firewall-cmd --permanent --add-port=69/udp
success
[root@mail ~]# firewall-cmd --reload
success

Configure syslinux service program

[root@mail ~]# yum install syslinux -y

[root@mail ~]# cd /var/lib/tftpboot/

[root@mail tftpboot]# cp /usr/share/syslinux/
altmbr.bin          gptmbr_c.bin        isolinux.bin        pwd.c32
altmbr_c.bin        gptmbr_f.bin        isolinux-debug.bin  pxechain.com
altmbr_f.bin        gpxecmd.c32         kbdmap.c32          pxelinux.0
cat.c32             gpxelinux.0         linux.c32           reboot.c32
chain.c32           gpxelinuxk.0        ls.c32              rosh.c32
cmd.c32             hdt.c32             lua.c32             sanboot.c32
config.c32          host.c32            mboot.c32           sdi.c32
cpuid.c32           ifcpu64.c32         mbr.bin             sysdump.c32
cpuidtest.c32       ifcpu.c32           mbr_c.bin           syslinux64.exe
diag/               ifplop.c32          mbr_f.bin           syslinux.com
disk.c32            int18.com           memdisk             syslinux.exe
dmitest.c32         isohdpfx.bin        memdump.com         ver.com
dosutil/            isohdpfx_c.bin      meminfo.c32         vesainfo.c32
elf.c32             isohdpfx_f.bin      menu.c32            vesamenu.c32
ethersel.c32        isohdppx.bin        pcitest.c32         vpdtest.c32
gfxboot.c32         isohdppx_c.bin      pmload.c32          whichsys.c32
gptmbr.bin          isohdppx_f.bin      poweroff.com        zzjson.c32
[root@mail tftpboot]# cp /usr/share/syslinux/pxelinux.0 .
[root@mail tftpboot]# cp /mnt/images/pxeboot/{vmlinuz,initrd.img} .
[root@mail tftpboot]# cp /mnt/isolinux/{vesamenu.c32,boot.msg} .
[root@mail tftpboot]# ls
boot.msg  initrd.img  pxelinux.0  vesamenu.c32  vmlinuz
[root@mail tftpboot]# mkdir pxelinux.cfg
[root@mail tftpboot]# cp /mnt/isolinux/isolinux.cfg pxelinux.cfg/default
[root@mail tftpboot]# vim pxelinux.cfg/default 

1 default linux

64   append initrd=initrd.img inst.stage2=ftp://192.168.56.25 ks=ftp://192.168.56.25/pub/ks.cfg quiet

Configure vsftpd service program

[root@mail tftpboot]# yum install vsftpd -y
[root@mail tftpboot]# systemctl restart vsftpd
[root@mail tftpboot]# systemctl enable vsftpd
ln -s '/usr/lib/systemd/system/vsftpd.service' '/etc/systemd/system/multi-user.target.wants/vsftpd.service'

[root@mail pub]# firewall-cmd --permanent --add-service=ftp
success
[root@mail pub]# firewall-cmd --reload
success
[root@mail pub]# setsebool -P ftpd_connect_all_unreserved=on

Create KickStart answer file

If you think that the default response file parameters of the system are less and cannot meet the requirements of the production environment, you can install the system config Kickstart software package through the Yum warehouse. This is a graphical tool for generating Kickstart response files, which can generate self defined response files according to your own needs

[root@mail ~]# cp anaconda-ks.cfg /var/ftp/pub/ks.cfg
[root@mail pub]# chmod 755 /var/ftp/pub/ks.cfg 

6 url --url=ftp://192.168.56.25
21 timezone Asia/Shanghai --isUtc
29 clearpart --all --initlabel 

Topics: vsftpd ftp yum firewall