Automatic installation using PXE CentOS7.6
Others
2019-10-02 19:37:30
views: null
First, demand
- New base 300 servers, we need to implement self-install CentOS7.6 version of the operating system, choose to use PXE batch installation.
Second, prepare for work
- Layer 2 switches connected to the server operating system is not installed, to avoid affecting the normal existing network server.
- Upload the operating system image to the server and install the PXE environment essential services.
- Mount image file as a local depot.
- Preparing the Environment
mkdir -p /var/www/html/CentOS1810/
mount /tmp/CentOS-7-x86_64-DVD-1810.iso /var/www/html/CentOS1810
mkdir /etc/yum.repos.d/backup
mv /etc/yum.repos.d/{*,backup} # 报错不需要理会
cat >/etc/yum.repos.d/local.repo<<EOF
[local_repo]
name=local_repo
baseurl=file:///var/www/html/CentOS1810
gpgcheck=0
EOF
yum clean all && yum makecache
yum install httpd dhcp xinetd tftp-server syslinux -y
Third, the service configuration
- The dhcp service
- Modify dhcp server configuration file
mv /etc/dhcp/dhcpd.conf{,.bak} # 备份默认配置文件
cat>/etc/dhcp/dhcpd.conf<<EOF
subnet 10.0.0.0 netmask 255.255.255.0 { # 定义分配的网段和掩码
range 10.0.0.1 10.0.0.252; # 定义分配的地址范围
next-server 10.0.0.253; # 指定引导文件的服务器IP地址
filename "pxelinux.0"; # 指定引导文件名称
}
EOF
systemctl start dhcp
systemctl enable dhcp
ss -nltup |grep :67
- Tftp-server configuration
- Edit /etc/xinetd.d/tftp file
sed -i '/disable/s/yes/no/' /etc/xinetd.d/tftp
systemctl start xinetd
systemctl enable xinetd
ss -nltup |grep :69
- Copy the boot files to the default home directory tftp service
cp -a /var/www/html/CentOS1810/isolinux/* /var/lib/tftpboot/
cp -a /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg
cp -a /var/www/html/CentOS1810/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
Origin www.cnblogs.com/liy36/p/11617963.html