How to automatically deploy Linux system using PXE

How to automatically deploy Linux system using PXE

Background

In a data center, dozens or even hundreds of servers are online at a time, and system installation becomes very troublesome. After the system is installed, it will involve a lot of configurations, and the workload is very large. Many virtualization platforms such as VMware and FusionCompute are usually installed one by one through ISO or through manufacturer tools, which is troublesome.

PXE is Pre-Boot Execution Environment
PXE technology for booting through the network card
1.BIOS support
2. Network card support
3. It needs to be enabled in BIOS; the server BMC interface is opened to deploy a server and install DHCP+tftp on the server (DHCP provides dynamic IP acquisition)
Network card DCHP obtains information
In addition to assigning IP addresses, DHCP can also provide the name of the boot program and the address of the TFTP server. The boot program is loaded into memory and booted according to the configuration file.

Ideas:

Configure the yum source to turn off firewall and selinux
Install dhcp, tftp-server, htppd, syslinux packages Configure dhcp, tftp-server, and start the service Install system-config-kickstart package and generate ks unattended script Configure boot menu

Configuring DHCP

Mount the CD

mount /dev/cdrom /media

Configure yum source

. `vim dvd.repo
	[development] #Define the later package selection name=centos
	baseurl=file:///media
	gpgcheck=0
	enabled=1`

Editing DHCP files (Dynamic Host Configuration Protocol)

cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf #Copy the template and overwrite the conf file
vim /etc/dhcp/dhcpd.conf #Choose between global configuration and sub-configuration.
   Global configuration# option definitions common to all supported networks...
  7 option domain-name "example.org";
  8 option domain-name-servers ns1.example.org, ns2.example.org;
  9 
 10 default-lease-time 600;
 11 max-lease-time 7200;
 12 next-server 192.168.100.10; #Specify where the tftpserver is 13 filename "/pxelinux.0"; #Network boot program file # Sub-configuration A slightly different configuration for an internal subnet.
 47 #Subnet configuration 48 subnet 192.168.100.0 netmask 255.255.255.0 {
 49 range 192.168.100.11 192.168.100.30; #DHCP address pool range 50 option domain-name-servers 192.168.100.2; #DNS address (can be set)
 51 option domain-name "example.com"; #Domain name address52 option routers 192.168.100.1; #Gateway address53 option broadcast-address 192.168.100.255; #Broadcast address54 default-lease-time 600; #How long does the IP obtained during the lease period survive55 max-lease-time 7200; #When the lease period expires, it can still be used if it is still available, otherwise it will be automatically recycled56 }

tftp configuration

[root@pxeserver ~]# vim /etc/xinetd.d/tftp 

# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
        socket_type = dgram
        protocol = udp
        wait = yes
        user = root
        server = /usr/sbin/in.tftpd
        server_args = -s /var/lib/tftpboot
        disable = no ##Change yes to no
        per_source = 11
        cps = 100 2
        flags = IPv4
}

syslinux configuration

yum provides "*/pxelinux.0" ##Find which package this file belongs to yum install -y syslinux #Install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ #Copy the pxelinux.0 file to the tftp root directory mkdir -p /var/lib/tftpboot/pxelinux.cfg #Place the default configuration file cp /media/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default ##Boot file cp to the pxeLinux.cfg directory cp /media/isolinux/* /var/lib/tftpboot/ #cpPlace the iso file and read it by default (the installation menu will be displayed)
There is no system configuration default file menu separator # insert an empty line
menu separator # insert an empty line
 
label linux
  menu label ^Install CentOS 7.5 #Menu directory kernel vmlinuz #Kernel file append initrd=initrd.img ks=http://192.168.100.10/ks/ks.cfg

Configure httpd

yum install -y httpd
systemctl start httpd
systemctl enable httpd
mkdir -p /var/www/html/centos
cp -rfv /media/* /var/www/html/centos/
[root@pxe-server ~]# cat /etc/yum.repos.d/dvd.repo 
[development] #Define the later selected package name=centos
baseurl=http://192.168.100.10/centos
gpgcheck=0
enabled=1

Configuring unattended

yum install -y system-config-kickstart
system-config-kickstart #Start

The specific configuration of the ks.cfg file is as follows:

insert image description here

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
The software package can be selected according to your needs. I chose the minimal installation here, so I chose a Base package
Write scripts to implement functions according to your needs

This is the end of this article about how to automate the deployment of Linux systems using PXE. For more information about PXE automated deployment of Linux, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed explanation of PXE+Kickstart unattended installation of operating system under CentOS 6.4
  • VMware implements the detailed process of PXE+kickstart unattended installation of Centos7 system
  • Detailed tutorial on how to automatically install CentOS7.6 using PXE
  • PXE kickstart automated deployment system installation

<<:  Detailed explanation of homology and cross-domain required for front-end interviews

>>:  Detailed explanation of the use of the <meta> tag in HTML

Recommend

Markup Language - List

Standardized design solutions - markup languages ...

Vue.js implements simple timer function

This article example shares the specific code of ...

The whole process record of introducing Vant framework into WeChat applet

Preface Sometimes I feel that the native UI of We...

How to load third-party component libraries on demand in Vue3

Preface Take Element Plus as an example to config...

Detailed explanation of Vue filters

<body> <div id="root"> <...

TypeScript namespace explanation

Table of contents 1. Definition and Use 1.1 Defin...

Mobile terminal adaptation makes px automatically converted to rem

Install postcss-pxtorem first: npm install postcs...

Common front-end JavaScript method encapsulation

Table of contents 1. Enter a value and return its...

Nginx domain name SSL certificate configuration (website http upgraded to https)

Preface HTTP and HTTPS In our daily life, common ...

How to use async and await correctly in JS loops

Table of contents Overview (Loop Mode - Common) D...

Summary of various forms of applying CSS styles in web pages

1. Inline style, placed in <body></body&g...

Implementation of one-click TLS encryption for docker remote api

Table of contents 1. Change the 2375 port of Dock...

Installation process of CentOS8 Linux 8.0.1905 (illustration)

As of now, the latest version of CentOS is CentOS...