Fully Automatic Network Installation of Linux-PXE

Preface:

Recent tidy up some of the previous study notes.
In the past, they were stored locally, and this time they were transferred to the network for reserve.

 

Advantages of network installation:

1) Scaling: assembling multiple mainframes at the same time;

2) Automation: automatic installation system, configuration and other services;

3. Remote implementation: no physical installation media such as CD-ROM and U-disk are needed.

 

PXE Network:

  • PXE = Pro-boot eXecution Environment

    • Pre-start the execution environment to run before the operating system;
    • It can be used for remote installation.
  • Working mode:

    • PXE client is integrated into the startup chip of the network card.
    • When the computer boots, the PXE client is loaded into memory from the network card chip for execution, and the configuration and display menu of the PXE server are obtained. The remote boot program is downloaded to the local computer according to the user's choice.
  • Required service components:

    • DHCP service: assign ip address, locate boot program;

      • Get ip
      • Specify the next server
      • Specify boot file
    • TFTP service: Provide bootstrap download;

      • Pxelinux.0 (boot file)
      • Pxelinux.cfg/default (menu file)
      • Vesamenu.32 (graphics module)
      • Splash. png (background)
      • Vmlinuz (kernel)
      • Initrd.img (driver)
    • HTTP service: (or FTP/NFS) provides yum installation source.

      • Software installation yum source
      • Kickstart (automatic response file) for automatic installation
  • Client requirements:

    • Network card chip must support PXE protocol.
    • The motherboard supports network card startup.

 

Building PXE Network Installation Server

  • Server address: 192.168.4.7  

1. Configure pxe settings for dhcp services:

1. Installation package: dhcp

]# yum -y install dhcp

2. Edit the configuration file: / etc/dhcp/dhcpd.conf

]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.4.0 netmask 255.255.255.0 {      #Declare network segment, subnet mask
    range 192.168.4.10 192.168.4.100;             #ip range
    option domain-name-servers 8.8.8.8;           #Domain Name Server
    option routers 192.168.4.254;                 #Routing address
    next-server 192.168.4.7;                      #Specify the address of the next execution server (PXE server), native
    filename "pxelinux.0";                        #Next server boot file, default pxelinux.0 after generation
}

3. Restart service: dhcpd

]# systemctl restart dhcpd      #Server ip must be guaranteed within the scope of dhcp

4. Confirmation results

]# netstat -utnap | grep dhcpd
udp 0 0 0.0.0.0:67 0.0.0.0:* 8380/dhcpd

5.dhclient test (client)

Temporary configuration/testing, dhclient is recommended
        - Format: dhclient-d [Network Interface]
        - Option: - d Debugging Mode
]# dhclient -d eth0

 

Second, build httpd services:

  • Provide yum source

1. Installation package: httpd

]# yum -y install httpd

2. Restart and self-start services:

]# systemctl restart httpd
]# systemctl enable httpd

3. Sharing CD Content: Mounting

]# mkdir /var/www/html/rhel7
]# mount /dvd/cdrom /var/www/html/rhel7

 

3. Build tftp service:

1. Installation package: tftp-server

]# yum -y install tftp-server

2. Restart and boot-up service:

]# systemctl restart tftp

3. Deploy PXE startup program:

Deployment boot file: pxelinux.0

  • pxelinux.0: The binary file of the network card boot file (installation instructions), which can be generated by installing a software.
    ]# yum provides */pxelinux.0                                #Software package for query generation of pxelinux.0
    ]# yum -y install sysliunx                                  #Install the queried package
    ]# rpm -ql syslinux | grep pxelinux.0                       #Query the path of pxelinux.0
    ]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/     #Copy boot file to tftpboot
    

3.2). Deployment menu file: isolinux.cfg

]# mkdir /var/lib/tftpboot/pxelinux.cfg/
]# cp /dvd/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
    #Copy the CD-ROM menu file to the default directory of tftp
]# chmod u+w /var/lib/tftpboot/pxelinux.cfg/default         #Give the right to write documents

Deployment graphics module: vesamenu. C32 (graphics module), splash. png (background picture)

]# cp /dvd/isolinux/vesamenu.c32 /dvd/isolinux/splash.png /var/lib/tftpboot

3.4. Deploy startup kernels and drivers: vmlinuz (startup kernels), initrd.img (drivers)

]# cp /dvd/isolinux/vmlinuz /dvd/isolinux/initrd.img /var/lib/tftpboot

Modify menu file: / var/lib/tftpboot/pxelinux.cfg/default

]# vim /var/lib/tftpboot/pxelinux.cfg/default
.. ..
default vesamenu.c32            #Modules that load graphics by default
timeout 600                     #Reading time 600 milliseconds
.. ..
menu background Background picture name      #Picture size 640*480
menu title Title
.. ..
label linux                     #menu
    menu label ^Options, menu content       #Display menu content
    kernel vmlinuz                   #Loading the kernel
    append initrd=initrd.img         #Load Driver
  • Preliminary tests:

    • Create a new virtual machine, select PXE network boot installation

 

4. Configure unattended installation and generate response files: ks.cfg

1. Install graphics tools: system-config-kickstart

]# yum -y install system-config-kickstart

2. Execution tool checks [package selection] to see if there are any packages:

]# system-config-kickstart
   # If not, the [source identifier] of the local yum configuration file needs to be changed to [development]
]# vim /etc/yum.repos.d/dvd.repo

3. Execution tool modification configuration:

]# system-config-kickstart

4. Save the configuration to / root and exit:

 

5. Share ks.cfg response files and use httpd services:

]# cp /root/ks.cfg /var/www/html

 

6. Modify menu files and specify ks.cfg response files:

]# vim /var/lib/tftpboot/pxelinux.cfg/default
label linux
    menu label  option
    kernel  vmlinuz
    append initrd=initrd.img  ks=http://192.168.4.7/ks.cfg

Keywords: Operation & Maintenance network yum vim Linux

Added by Javizy on Mon, 22 Jul 2019 08:54:32 +0300