LinuxPXE+Kickstrart Unattended Installation Service

Keywords: Linux ftp firewall vsftpd yum

Requirements: Turn off your own DHCP service in VMware Virtual Network Editor

Host Name operating system IP Address
NoneOS Centos7 192.168.72.250
Custormer nothing  

 

 

1. Hang in local mirror source This configuration Yum repository, install DHCP service

[root@NoneOs ~]# yum install dhcp -y

2. Configuring DHCP services

[root@NoneOs ~]# vim /etc/dhcp/dhcpd.conf

allow booting;
allow bootp;
ddns-update-style interim;
ignore client-updates;
subnet 192.168.72.0 netmask 255.255.255.0 {
        option subnet-mask 255.255.255.0;
        option domain-name-servers 192.168.72.250;
        range dynamic-bootp 192.168.72.100 192.168.72.200;
        default-lease-time 21600;
        max-lease-time 43200;
        next-server 192.168.72.250;
        filename "pxelinux.0";
}

[root@NoneOs ~]# systemctl restart dhcpd
[root@NoneOs ~]# systemctl enable dhcpd
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.

 

3. Configure TFTP service program

[root@NoneOs ~]# yum install tftp-server -y

service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

[root@NoneOs ~]# systemctl restart xinetd
[root@NoneOs ~]# systemctl enable xinetd

 

The TFTP service program uses the UDP protocol by default, takes up 69 ports, and needs to write a permission policy in the firewalld firewall tool to make it permanent in the production environment.

firewall-cmd --permanent --add-port=69/udp
firewall-cmd --reload

Firewall can be turned off directly in an experimental environment

[root@NoneOs ~]# systemctl stop firewalld

4. SYSlinux Service

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

 

First copy the boot file provided by SYSlinux to the default directory of the TFTP service program, which was previously pxelinux.0, so that the client host can get the boot file smoothly.You also need to invoke some boot files for some of the Centos7 disc images, confirm that the disc images are hung locally, and then copy some of the boot files to the default directory of the TFTP service program.

[root@NoneOs tftpboot]# cp /usr/share/syslinux/pxelinux.0 .
[root@NoneOs tftpboot]# cp /media/images/pxeboot/{vmlinuz,initrd.img} .
[root@NoneOs tftpboot]# cp /media/isolinux/{vesamenu.c32,boot.msg} .

Then create a new pxelinux.cfg directory in the directory of the TFTP service program, which is a directory with a suffix.Copy the startup options menu from the system CD into this directory and name it default

[root@NoneOs tftpboot]# mkdir pxelinux.cfg
[root@NoneOs tftpboot]# cp /media/isolinux/isolinux.cfg pxelinux.cfg/default

Modify the copied default file

[root@NoneOs tftpboot]# vim pxelinux.cfg/default
 1 default linux

64 append initrd=initrd.img inst.stage2=ftp://192.168.72.250 ks=ftp://192.168.7    2.250/pub/ks.cfg quiet

5. Configure vsftpd service

The vsfptd service is used because the disc image is transmitted over the FTP protocol.

[root@NoneOs ~]# yum install vsftpd -y

 [root@NoneOs ~]# systemctl restart vsftpd


 [root@NoneOs ~]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.

 

After confirming that the disc image files are normally hung in the local directory, copy all the disc image files in the directory to the working directory of vsftpd.

[root@NoneOs ~]# cp -r /media/* /var/ftp/

In a production environment, the FTP protocol needs to be written into the firewalld firewall with a permanently valid permission policy, and then FTP transmission is released in SELINUX:

firewall-cmd --permanent --add-service=ftp

firewall-cmd --reload

setsebool -P ftpd_connect_all_unreserved=on

6. Create KickStart Answer File

kisckStart is not a service program, but an answer file that contains options and parameter information for system installation. The system can automatically invoke the contents of this answer file to implement unattended installation of the system.

This file is named anaconda-ks.cfg in the root administrator's home directory.

 

[root@NoneOs ~]# cp -r /media/* /var/ftp/
[root@NoneOs ~]# cp ~/anaconda-ks.cfg /var/ftp/pub/ks.cfg
[root@NoneOs ~]# chmod +r /var/ftp/pub/ks.cfg
[root@NoneOs ~]# vim /var/ftp/pub/ks.cfg
5 url --url=ftp://192.168.72.250
23 timezone Asia/Shanghai --isUtc
28 clearpart --all --initlabel

 

7. Automatically deploy client hosts

 

 

 

 

 

 

 

 

Network Mode Selection Host Only

 

Automatic installation without manual intervention

Posted by jaykappy on Thu, 29 Aug 2019 18:42:01 -0700