System Automation Installation~PEX

PXE System Automation Installation --- Summary of Seven Weeks'Contents

Using PXE to Realize Automatic Installation System

Prerequisite:

Network Card: Host Only, Close vmware's dhcp Service

1 HTTP

Install http software
    yum install httpd 
Start the service and set it to boot from scratch
    systemctl start httpd 
    systemctl enable httpd

Create a mirror mount directory and mount it
    cd /var/www/html
    mkdir centos/{6,7}/os/x86_64
    mount /dev/sr0    /var/www/html/centos/7/os/x86_64
    mount /dev/sr1    /var/www/html/centos/6/os/x86_64
 View accessibility through a browser

2 Prepare KS files

Install kickstart software
     yum -y install systemm-config-kickstart
 Generate and save ks7_mini.cfg and ks6_mini.cfg files
    system-config-kickstart
    (In the package installation column, centos7 needs to change the name of the yum configuration file to [development])
Modify ks configuration file
    mv /root/ks*.cfg /var/www/html/
    vim ks7_mini.cfg
        url --url="http://192.168.7.7/centos/7/os/x86_64/"
    vim /var/www/html/ks6_mini.cfg
        url --url="http://192.168.7.7/centos/6/os/x86_64/"

3 tftp

Install tftp-server software
    yum install tftp-server
 Start and set to boot-up
    systemctl start tftp
    systemctl enable  tftp

4 DHCP services

install dhcp Software
    yum install dhcp
//Modify dhcp.conf file by referring to self-contained file
    cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
    vim  /etc/dhcp/dhcpd.confddd
        option domain-name "magedu.com";
        option domain-name-servers 114.114.114.114, 223.5.5.5;
        default-lease-time 86400 ;
        max-lease-time 864000;
        subnet 192.168.7.0 netmask 255.255.255.0 {
        range 192.168.7.10 192.168.7.100;
        option routers 192.168.7.254;
        next-server 192.168.7.7;
        filename "pxelinux.0";
        }
//Start the service and set it to boot from scratch
    systemctl start dhcpd
    systemctl enable dhcpd

5 Prepare startup file

install syslinux Software
    yum install syslinux 
//Copy files to tftpboot
    cp /usr/share/syslinux/pxelinux.0  /var/lib/tftpboot 
    cp /usr/share/syslinux/menu.c32    /var/lib/tftpboot
    cp /misc/cd/isolinux/vmlinuz      /var/lib/tftpboot/
    cp /misc/cd/isolinux/initrd.img  /var/lib/tftpboot/
//Create pxelinux.cfg folder
    mkdir /var/lib/tftpboot/pxelinux.cfg/
//Copy the mirror file and rename it
    cp /misc/cd/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
//View the tree structure of the tftpboot folder
    tree /var/lib/tftpboot/
        /var/lib/tftpboot/
        ├── initrd.img
        ├── menu.c32
        ├── pxelinux.0
        ├── pxelinux.cfg
        │   └── default
        └── vmlinuz

        1 directory, 5 files

6 Prepare to start menu file

Modify Start Menu Profile
    vim /var/lib/tftpboot/pxelinux.cfg/default
        default menu.c32
        timeout 60
        menu title Auto Install CentOS 
        label centos7 
        menu label Install CentOS ^Mini 7
        kernel vmlinuz
        append initrd=initrd.img ks=http://192.168.7.7/ksdir/ks7_mini.cfg
        label local
        menu default
        menu label Boot from ^local drive
        localboot 0xffff

7 to support multiple systems

Create System Corresponding Folder
    mkdir /var/lib/tftpboot/kernel{6,7}
//Move the system kernel file to the corresponding file directory
    cd /var/lib/tftpboot/
    mv vmlinuz initrd.img kernel7/
    cp /var/www/html/centos/6/os/x86_64/isolinux/vmlinuz kernel6
    cp /var/www/html/centos/6/os/x86_64/isolinux/initrd.img kernel6/
//View the tftpboot directory structure
    tree /var/lib/tftpboot/
    /var/lib/tftpboot/
    ├── kernel6
    │   ├── initrd.img
    │   └── vmlinuz
    ├── kernel7
    │   ├── initrd.img
    │   └── vmlinuz
    ├── menu.c32
    ├── pxelinux.0
    └── pxelinux.cfg
        └── default

    3 directories, 7 files

//Modify Start Menu File
    vim /var/lib/tftpboot/pxelinux.cfg/default
        default menu.c32
        timeout 60
        menu title Auto Install CentOS 
        label centos7 
        menu label Install CentOS ^Mini 7
        kernel kernel7/vmlinuz
        append initrd=kernel7/initrd.img ks=http://192.168.7.7/ksdir/ks7_mini.cfg
        label centos6
        menu label Install CentOS Mi^ni 6
        kernel kernel6/vmlinuz
        append initrd=kernel6/initrd.img ks=http://192.168.7.7/ksdir/ks6_mini.cfg
        label local
        menu default
        menu label Boot from ^local drive
        localboot 0xffff

dhcp details

Main uses

* Used for internal network and network service providers to automatically assign ip addresses to users
 * Used by internal network administrators as a means of centralized management of all computers

Usage scenarios

* Automatic Installation System
 * Solving the problem of insufficient ipv4 resources

dhcp implementation

1. Prerequisite: The system network card is set to host-only mode, and the dhcp service of vmware is cancelled.
2. Install dhcp software
 3. View and modify the dhcp configuration file
    cat /etc/dhcp/dhcpd.conf
    cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
    vim /etc/dhcp/dhcpd.conf
        Modify 7 lines: option domain-name "example.org" 
        Modify lines 10-11: Address lease, usable time, in seconds
        Delete lines 27-28
        Modify lines 32-34: Set the same segment as the server, gateway and dns
        Save exit
 4. Start dhcp service
 5. Modify client ip configuration file, change BOOTPROTO to dhcp, restart configuration file
 6. View the client ip address
 7. The server looks at the client to get ip information
    cd /var/lib/dhcpd
    cat dhcpd.leases
 8. Client view to get ip address information
    cd /var/lib/dhclient/
    cat dhclient-*

Tags: Linux CentOS yum vim network

Posted on Mon, 29 Apr 2019 08:30:36 -0700 by scottrad