CentOS7 operation and maintenance-PXE remote installation service
- Requirements for building
- Build a PXE remote installation server
- 1. Install TFTP and Xinetd and enable
- 2. Install and enable the DHCP service
- Three, prepare the kernel and image files
- Fourth, prepare the PEX boot program
- Five, install FTP|Prepare CentOS7 installation source
- Six, configure the boot menu file
- Seven, realize Kickstart unattended installation
- Eight, create a new virtual machine inspection
PXE
(Pre-boot operating environment) is Inter
a network boot technology developed by the company, working in C/S
mode, allowing clients to download boot images from remote servers through the network, and load installation files or the entire operating system
Requirements for building
- The client's network card must support the
PXE
protocol (integratedBOOTROM
chip), and the motherboard supports network boot. Generally most servers support it, only needBIOS
to allow fromNetwork
orLAN
start in the settings - There is a
DHCP
server in the network to automatically assign addresses and specify the location of the boot file for clients - The server must
TFTP
provide the download of the boot image file through the service (Simple File Transfer Protocol)
Build a PXE remote installation server
PXE
The remote installation server integrates CentOS7
installation sources, TFTP
services, and DHCP
services, and can send PXE
bootloaders, Linux
kernels, boot menus and other data to the client bare metal , as well as provide installation files
1. Install TFTP and Xinetd and enable
TFTP
(Simple File Transfer Protocol) is a UDP
protocol- based protocol for simple file transfer between client and server, suitable for small file transfer applications. TFTP
The service is managed by the xinetd
service by default , use UDP
port69
xinetd
It is a new generation of network daemon service program, also called super server, commonly used to manage a variety of lightweight Internet
services
yum -y install tftp-server xinetd
vim /etc/xinetd.d/tftp
Modify the configuration
wait = {}
value set to no
disable = {}
value setno
service tftp
{
socket_type = dgram
protocol = udp
wait = no
#wait no表示客户机可以多台一起连接,yes表示客户机只能一台一台连接
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
#disable no表示开启TFTP服务
per_source = 11
cps = 100 2
flags = IPv4
}
Open service
systemctl start tftp
systemctl start xinetd
2. Install and enable the DHCP service
yum -y install dhcp
vim /etc/dhcp/dhcpd.conf
:r /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example
// 使用vi命令行指令将样式文件内容写入到当前文件
ddns-update-style none;
// 禁止动态更新
next-server IP;
// 指定 TFTP 服务器的地址
filename "pxelinux.0";
// 指定要下载的 PXE 引导程序的文件
subnet 网段 netmask 掩码 {
range 地址池IP 地址池IP;
option routers TFTP服务器IP;
}
Open service
systemctl start dhcpd
Three, prepare the kernel and image files
Mount the CD and enter the directory/mnt/images/pxeboot
mount /dev/cdrom /mnt
cd /mnt/images/pxeboot/
Will initrd.img
and vmlinuz
copied to tftpboot
the
cp initrd.img /var/lib/tftpboot/
cp vmlinuz /var/lib/tftpboot/
Fourth, prepare the PEX boot program
yum -y install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
Five, install FTP|Prepare CentOS7 installation source
yum -y install vsftpd
mkdir /var/ftp/centos7
cp -rf /mnt/* /var/ftp/centos7/
// 将镜像复制其中
或者
mount /dev/sr0 /var/ftp/centos7
systemctl start vsftpd
// 开启服务
Six, configure the boot menu file
Default boot menu file in TFTP
the root directory of the pxelinux.cfg
subdirectory, the file namedefault
mkdir /var/lib/tftpboot/pxelinux.cfg
vim /var/lib/tftpboot/pxelinux.cfg/default
default auto #指定默认入口名称
prompt 1 #设置是否等待用户选择,“1”表示等待用户控制
label auto #图形安装(默认)引导入口,label 用来定义启动项
kernel vmlinuz #kernel 和 append用来定义引导参数
append initrd=initrd.img method=ftp://192.168.1.1/centos7
label linux text #文本安装引导入口
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.1.1/centos7
label linux rescue #救援模式引导入口
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.1.1/centos7
systemctl stop firewalld.service #关闭系统防火墙
setenforce 0 #关闭系统安全机制
Seven, realize Kickstart unattended installation
① Prepare to install the answer file
yum install -y system-config-kickstart #安装system-config-kickstart 工具
②Open the Kickstart configuration program
Use desktop mode to open
Use instructions to open
system-config-kickstart
③ Placement Kickstart
The default language is set to 中文(简体)
the time zone to Asia/Shanghai
set up root
a password
advanced configuration check 安装后重启
installation method selected FTP
FTP server ftp://TFTPIP
FTP directorycentos7
Master Boot Record: 清除主引导记录
Partition: 删除所有现存分区
Disk Label:初始化磁盘标签
挂载点:/boot,文件系统类型:xfs,固定大小:500M
文件系统类型:swap,固定大小:4096M
挂载点:/home,文件系统类型:xfs,固定大小:4096M
挂载点:/,文件系统类型:xfs,使用磁盘上全部未使用空间
Adding network equipment ens33
network type to DHCP
the firewall as needed to select
post-install script
Check "Use Interpreter:/bin/bash
rm -rf /etc/yum.repos.d/*
echo '[local]
name=local
baseurl=ftp://192.168.1.1/centos7
enabled=1
gpgcheck=0' > /etc/yum.repos.d/local.repo
Save the file in the root directory
④Configuration package
vim ks.cfg
Add to the end
%packages
@^graphical-server-environment
@base
@core
@desktop-debugging
@development
@dial-up
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@hardware-monitoring
@input-methods
@internet-browser
@multimedia
@print-client
@x11
chrony
%end
If you require minimal installation, you can copy the following
vim ks.cfg
%packages
@^minimal
%end
Copy /root/anaconda-ks.cfg
the package installation script of /var/ftp/ks.cfg
to for desktop installation
cp /root/ks.cfg /var/ftp/ks.cfg
⑤Add ks boot parameters to the boot menu file
vim /var/lib/tftpboot/pxelinux.cfg/default
Eight, create a new virtual machine inspection
No action required