当前位置:网站首页>PXE_ KS unattended system
PXE_ KS unattended system
2022-07-28 20:32:00 【Operation and maintenance log of Panax notoginseng】
Unattended installation PXE+KS
Unattended installation is a program about Automation ( In short, configure the server , All clients in the LAN can automatically obtain from the server without choosing to install the system IP Address , Automatically install the system according to the configuration of the server )
structure

install
install dhcp
yum -y install dhcp
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
mv: Is it covered? "/etc/dhcp/dhcpd.conf"? y
Modify the configuration , Add a new one subnet
vim /etc/dhcp/dhcpd.conf
subnet 192.168.5.0 netmask 255.255.255.0 {
range 192.168.5.160 192.168.5.170;
next-server 192.168.5.7; # The address of the next server , That is to say tftp Of IP Address
filename "pxelinux.0"; # Boot file name , Indicates the boot file name
}
Restart the service
systemctl restart dhcpd
install xinetd, Boot up tftpd-server The server , You need to use configuration xinetd The server
yum -y install xinetd
vim /etc/xinetd.d/tftp
disable = no # Make it effective
install tftp-server service
yum -y install tftp-server
When installing and using sysLinux, Provide pxelinux.0 file , If so, don't install
yum -y install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ # Copy the bootstrap file of the remote installation
Copy the boot files and other files necessary for the new system
mkdir /mount
vim /etc/fstab # Mount the CD first , Mount to mount
/dev/sr0 /mount iso9660 defaults 0 0 # Mount format
mount -a # Reload
mount: /dev/sr0 Write protect , Will mount... As read-only
cp /mount/images/pxeboot/vmlinuz /var/lib/tftpboot/
cp /mount/images/pxeboot/initrd.img /var/lib/tftpboot/
cp /mount/isolinux/vesamenu.c32 /var/lib/tftpboot/
cp /mount/isolinux/boot.* /var/lib/tftpboot/
Copy a configuration file for the bootstrap
stay /var/lib/tftpboot/ Create a new directory , Directory name pxelinux.cfg, Copy /mount/isolinux/isolinux.cfg File to pxelinux.cfg The directory is named default
mkdir /var/lib/tftpboot/pxelinux.cfg
cp /mount/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
Edit profile : Tell access to tftp The complete system of the client of the service IP Address and path , also ks( System installation procedure record file ) Of documents IP Address and path
vim /var/lib/tftpboot/pxelinux.cfg/default
default linux # Manual selection during startup can be omitted install centos7
append initrd=initrd.img inst.stage2=ftp://192.168.5.7/centos ks=ftp://192.168.5.7/centos/ks.cfg quiet
install ftp, Copy the complete operating system
yum -y install vsftpd
mkdir /var/ftp/centos
Copy the complete operating system to tftp The path specified by the configuration file , front tftp The configuration file is written as ftp://192.168.5.7/centos, So it will automatically address to ftp Under the centos
cp -r /mount/* /var/ftp/centos/ #-r duplicate catalog
The new system is generated by the replication server host ks file , Automatically perform the same operation as the server host during installation
cp /root/anaconda-ks.cfg /var/ftp/centos/ks.cfg
chmod +r /var/ftp/centos/ks.cfg # Add executable rights
edit ks file
vim /var/ftp/centos/ks.cfg
url --url="ftp://192.168.5.7/centos" # Tell the client to pass ftp Shared directory centos install
reboot # restart
eula --agreed # Agree to the agreement
Restart the service , Turn off firewall , Turn off use syslinux
systemctl restart tftp
systemctl restart xinetd
systemctl restart vsftpd
systemctl restart dhcpd
systemctl stop firewalld
setenforce 0
verification
New virtual machine
configure hardware
Memory 2GB above
Do not select an operating system
Turn on the virtual machine
shell Script
vim pxe_ks.sh
About improving : Take various parameters such as IP Addresses and different paths of different devices can be made into variables
#!/bin/bash
# Prompt information
echo "!!! Please confirm that the virtual machine is CD/DVD Whether to set connected ?"
echo "!!! Please make sure the PXE Whether the parameters of the script have been modified ?"
echo "!!! Please confirm whether the virtual machine image path is set ?"
echo "!!! Please make sure the yum Whether sleep needs rm -f /var/run/yum.pid?"
echo "!!! Not set to be available in 5 In seconds ctrl+c end !!"
sleep 5 # Sleep five seconds
# Determine whether to mount
grep mount_cdrom /etc/fstab > /dev/null 2>&1 # All output is redirected to null
if [ $? -eq 0 ] ; then
echo " CD reload .."
mount -a
sleep 0
echo " The CD has been mounted successfully !!"
else
echo " Mounting CD .."
echo "/dev/sr0 /mount_cdrom iso9660 defaults 0 0" >> /etc/fstab
echo " Creating a new mount directory .."
sleep 2
mkdir /mount_cdrom
echo " CD reload .."
sleep 2
mount -a
echo " CD reload successful !!"
fi
# install dhcp
echo " Ready to install dhcp.."
ls /usr/share/doc/dhcp*/dhcpd.conf.example > /dev/null 2>&1
if [ $? -eq 0 ] ; then
echo "DHCP already installed !!"
else
echo " Installing DHCP, Please later .."
rm -f /var/run/yum.pid
yum -y install dhcp
fi
# To configure dhcp
echo " Configuring DHCP The configuration file .."
sleep 2
\cp /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf # The backslash can not prompt whether to overwrite the file
sed -i '36 a\subnet 192.168.5.0 netmask 255.255.255.0 {\n range 192.168.5.160 192.168.5.170;\n next-server 192.168.5.7;\n filename "pxelinux.0";\n}\n' /etc/dhcp/dhcpd.conf
echo " Restart DHCP.."
systemctl restart dhcpd
# install xinetd and tftp-server
rpm -qa | grep xinetd
if [ $? -eq 0 ] ; then
echo "xinetd Is already installed !!"
else
echo "xinetd Installing .."
yum -y install xinetd
echo "xinetd Is already installed !!"
fi
rpm -qa | grep tftp-server
if [ $? -eq 0 ] ; then
echo "tftp Is already installed !!"
else
echo "tftp Installing .."
yum -y install tftp-server
echo "tftp Is already installed !!"
fi
# Replace xinetd Of tftp To configure
sed -i '14d' /etc/xinetd.d/tftp # Delete 14 That's ok
sed -i '13 a\ disable = no' /etc/xinetd.d/tftp # stay 13 Add a new... After the line 14 That's ok
# The new system provides pxelinux.0 file
rpm -qa | grep syslinux > /dev/null 2>&1
if [ $? -eq 0 ] ; then
echo 'syslinux Is already installed !!'
else
echo ' Installing syslinux..'
yum -y install syslinux
echo 'syslinux Installation successful !!'
fi
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
# Copy the boot files necessary for system installation
echo ' Copying boot files required for system installation ..'
sleep 2
cp /mount_cdrom/images/pxeboot/vmlinuz /var/lib/tftpboot/
cp /mount_cdrom/images/pxeboot/initrd.img /var/lib/tftpboot/
cp /mount_cdrom/isolinux/vesamenu.c32 /var/lib/tftpboot/
cp /mount_cdrom/isolinux/boot.* /var/lib/tftpboot/
if [ $? -eq 0 ] ; then
echo ' Replication success !!'
fi
# Make a configuration file for the bootstrap
echo ' Making configuration file for bootstrapper ..'
sleep 2
if [ -e /var/lib/tftpboot/pxelinux.cfg ] ; then
echo "pxelinux.cfg Already exists , No need to make !!"
else
mkdir /var/lib/tftpboot/pxelinux.cfg
fi
\cp /mount_cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
sed -i '1d' /var/lib/tftpboot/pxelinux.cfg/default
sed -i '1 i\default linux' /var/lib/tftpboot/pxelinux.cfg/default
sed -i '64d' /var/lib/tftpboot/pxelinux.cfg/default
sed -i '63 a\ append initrd=initrd.img inst.stage2=ftp://192.168.5.7/centos ks=ftp://192.168.5.7/centos/ks.cfg quiet' /var/lib/tftpboot/pxelinux.cfg/default
if [ $? -eq 0 ] ; then
echo ' The bootstrap configuration file is finished !!'
fi
# install ftp
rpm -qa | grep vsftpd
if [ $? -eq 0 ] ; then
echo 'vsftpd Is already installed !!'
else
echo ' Installing vsftpd'
yum -y install vsftpd
echo 'vsftpd Installation successful !!'
fi
# Copy the complete operating system to tftp The path specified by the configuration file
mkdir /var/ftp/centos
echo ' Copying full operating system , Please wait a few minutes ..'
cp -r /mount_cdrom/* /var/ftp/centos/
echo ' The complete operating system was copied successfully !!'
# Make for the new system ks file
echo ' Is making ks file ..'
sleep 2
cp /root/anaconda-ks.cfg /var/ftp/centos/ks.cfg
chmod +r /var/ftp/centos/ks.cfg
sed -i '22d' /var/ftp/centos/ks.cfg
sed -i '21 a\url --url="ftp://192.168.5.7/centos"' /var/ftp/centos/ks.cfg
sed -i '68 a\reboot\neula --agreed' /var/ftp/centos/ks.cfg
echo 'ks The file was created successfully !!'
# Restart the service , Turn off firewall , Turn off use syslinux
echo ' Restarting service , Turn off firewall '
systemctl restart tftp
systemctl restart xinetd
systemctl restart vsftpd
systemctl restart dhcpd
systemctl stop firewalld
setenforce 0
echo ' Restart service succeeded , Firewall closed successfully !!'
# end
yum -y install sl > /dev/null 2>&1 # A small train program
echo '.......................'
echo '.......................'
echo 'PXE-KS The unattended program of the operating system was successfully deployed !!'
echo '.......................'
echo '.......................'
sl
echo ‘ Restart service succeeded , Firewall closed successfully !!’
# end
yum -y install sl > /dev/null 2>&1 # A small train program
echo ‘…’
echo ‘…’
echo ‘PXE-KS The unattended program of the operating system was successfully deployed !!’
echo ‘…’
echo ‘…’
sl
边栏推荐
- Raspberry pie 4B uses MNN to deploy yolov5 Lite
- Simple use of robobrowser
- 通配符 SSL/TLS 证书
- Solutions to the environment created by Anaconda that cannot be displayed in pycharm
- 太空射击第14课: 玩家生命
- Does any elder brother know how to solve the huge flinksql log
- 七种轮询介绍(后附实践链接)
- Anaconda creation environment
- robobrowser的简单使用
- The product power is greatly improved, and the new Ford Explorer is released
猜你喜欢

【实验分享】CCIE—BGP反射器实验

NEIL: Extracting Visual Knowledge from Web Data
![[C language] comprehensively analyze the pointer and sort out the pointer knowledge points](/img/71/f4138b68c27d6447fbd5b5e0762929.png)
[C language] comprehensively analyze the pointer and sort out the pointer knowledge points

Reverse string

Zfoo adds routes similar to mydog

Use of DDR3 (axi4) in Xilinx vivado (2) read write design

Usage Summary of thymeleaf

Explain RESNET residual network in detail

Read JSON configuration file to realize data-driven testing

The product power is greatly improved, and the new Ford Explorer is released
随机推荐
LeetCode_ Bit operation_ Medium_ 260. Number III that appears only once
Solve the brick stacking problem (DP)
Raspberry pie uses the command line to configure WiFi connections
GRU神经网络
Use of DDR3 (axi4) in Xilinx vivado (1) create an IP core
Raspberry pie 4B ffmpeg RTMP streaming
Product manager interview | innovation and background of the fifth generation verification code
[C language] guessing numbers game
太空射击第15课: 道具
Solve the problem of adding the least number of parentheses (interval DP)
Solutions to the environment created by Anaconda that cannot be displayed in pycharm
JVM (24) -- performance monitoring and tuning (5) -- Analyzing GC logs
lattice
Related concepts of multitasking programming
Use of DDR3 (axi4) in Xilinx vivado (5) board test
Maximum exchange [greedy thought & monotonic stack implementation]
local/chain/run_ tdnn.sh:
Data mining (data preprocessing) -- Notes
How to use pycharm to quickly create a flask project
Character device drive structure