Automatically install CentOS 7.6 using PXE
Keywords:
Linux
yum
SELinux
CentOS
network
I. demand
- Base new to 300 servers, need to install the operating system version 7.6 of CentOS, choose to use PXE for batch installation.
II. Preparations
- Use the layer-2 switch to connect the server without the operating system installed, so as to avoid affecting the normal server of the current network.
- Upload the operating system image to the server and install the necessary services for the PXE environment.
- Mount the mirror file as the local software repository.
- Environmental preparation
systemctl stop firewalld # Close the firewall
setenforce 0 # Temporarily set SELINUX to loose mode
sed -i '/^SELINUX=/s/.*/SELINUX=disabled/' /etc/selinux/config # Permanently disable SELINUX (restart is required to take effect)
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} # Mistakes need not be ignored
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
III. Service Configuration
- Configuring dhcp services
- Modify dhcp server configuration file
mv /etc/dhcp/dhcpd.conf{,.bak} # Back up default configuration files
cat>/etc/dhcp/dhcpd.conf<<EOF
subnet 10.0.0.0 netmask 255.255.255.0 { # Define allocated segments and masks
range 10.0.0.1 10.0.0.252; # Define the range of addresses allocated
next-server 10.0.0.253; # Specify the server IP address of the boot file
filename "pxelinux.0"; # Specify boot file name
}
EOF
systemctl start dhcp
systemctl enable dhcp
ss -nltup |grep :67
- Configure tftp-server
- 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 related files to the default home directory of tftp service
mkdir /var/lib/tftpboot/pxelinux.cfg
cp -a {/var/www/html/CentOS1810/isolinux/*,/usr/share/syslinux/pxelinux.0} /var/lib/tftpboot/
cp -a /var/www/html/CentOS1810/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
Posted by karenn1 on Sat, 05 Oct 2019 14:47:46 -0700