Linux unattended installation that you can understand at a glance!!!

Unattended installation
Through the method of network boot system, we can get rid of the tedious media such as CD, hard disk, USB to boot, and install multiple machines completely through the network. It is easy and fast to install.
Function of PXE: it is equivalent to a small system in ROM. it provides the network boot function to the BIOS of the system through a standard API, and then Linux can be started through the network.
PXE network boot process: the machine requests an IP address from the DHCP server by sending a broadcast, and then the DHCP server will send a DHCP package containing PXE to the requesting client as its corresponding (boot server IP address and boot file name). The client transfers and downloads the boot file through TFTP and executes the boot file.
Kickstart is used for automatic installation and installation (human intervention, such as partition, root password, graphical or minimal installation). Its tools are system config kickstart and syslinux.

Use of services and tools
PXE+TFTP+VSTFP+Kickstart+PXE+DHCP

1, Implementation process

Server: 192.168.12.10
Client: Auto acquire (DHCP)

Configure yum source

  1. Modify the yum file vim /etc/yum.repos.d/CentOS.repo and save it
[Slave-CentOS]  //yum source name
name=Slave-CentOS  //Identification
enable=1  //Boot from boot
baseurl=file:///mnt / / local yum address
gpgcheck=0    //Self checking on startup

Configure VSFTPD service

  1. Download vsftpd and xinetd services
yum install vsftpd   -y
  1. Restart vsftp service
systemctl restart vsftpd
  1. Add boot entry
systemctl enable vsftpd

Configure TFTP service

  1. Download TFTP, TFTP server and xinnetd services
yum install tftp tftp-server xinetd -y

Note: check whether the service has been downloaded after downloading
rpm -qa tftp/tftp-server/xinetd
2. Modify TFTP service
vim /etc/xinetd.d/tftp
Modify lines 13 and 14 in the configuration file. Change to the following:

 13   server_args     = -s /tftpboot -c 
 14   disable         = no

server_args = -s /tftpboot -c / / indicates that the default directory of the server is / tftpboot; - C transfers files directly without putting a.txt
3. Restart the service

systemctl restart xinetd
  1. Add boot entry
systemctl enable xinetd

tftp is a lightweight service, xinetd is the daemons of many lightweight services (including tftp)
4. Check whether port 69 is monitored

netstat  -antup | grep 69 
udp   0   0 0.0.0.0:69    0.0.0.0:*  6593/xinetd         
udp6  0   0 :::69         :::*       1/systemd    

Configure DHCP service
5. Download DHCP

yum install dhcp -y
  1. Modify DHCP profile
    vim /etc/dhcp/dhcpd.conf
subnet 192.168.12.0 netmask 255.255.255.0 {
        range 192.168.12.55 192.168.12.60;
        option domain-name "www.dhcp.com";
        oprion domain-name-servers 192.168.12.10;
        option routers 192.168.12.10;
        default-lease-time 600;
        max-lease-time 7200;
        filename "pxelinux.0";
}

Note: restart the DHCP service first, and then restart it together

Prepare PXE boot related files

  1. Create tftp file / tftpboot
mkdir /tftpboot
mkdir /tftpboot/pxelinux.cfg
  1. Prepare file share for boot
cp -a /usr/share/syslinux/pxelinux.0 /tftpboot/ 
//Syslinux is available only when system config kickstart and syslinux are downloaded 
cp -a /mnt/images/pxeboot/initrd.img /tftpboot/
cp -a /mnt/images/pxeboot/vmlinuz /tftpboot/
cp -a /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
chmod 644 /tftpboot/pxelinux.cfg/default  //Empower default

3. Modify the default file, specify the installation method path and ks.cfg file path
Change line 1 to read:

default linux

Note: indicates to specify the default entry name;
Change line 64 to read

append initrd=initrd.img inst.repo=ftp://192.168.12.10/pub inst.ks=ftp://192.168.12.10/ks.cfg

Configuration preparation before installation

  1. Download System config kickstart and syslinux
yum install system-config-kickstart syslinux -y 
  1. System config kickstart enters the graphical interface for configuration

    Required partition
    /20480 (unit M)
    /boot 500
    swap 4096

Start DHCP service and add boot entry

Turn off firewalld

Turn off selinux temporarily

Modify yum configuration file

  1. vim /etc/yum.repos.d/CentOS.repo
[development]
name=Slave-CentOS
enable=1
baseurl=file:///var/ftp/pub
gpgcheck=0
  1. The mount point of the CD is modified to / var/ftp/pub
    Uninstall the original / mnt mount point first, then mount
mount /dev/sr0 /var/ftp/pub

The network mode of the two machines is: VMnet4 sets an IP for the server with the same network segment defined by DHCP

[^ 1]: if there is any error or other, please click it and it will be modified

Published 1 original article, praised 0 and visited 1
Private letter follow

Tags: yum network CentOS vsftpd

Posted on Thu, 16 Jan 2020 06:16:00 -0800 by fiona