是基于VMware虚拟机上安装实验的!
#!/bin/bash
#修改IP地址
#sed -i 's/dhcp/static/' /etc/sysconfig/network-scripts/ifcfg-ens32
#echo "
#IPADDR=192.168.100.100
#NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-ens32
#systemctl restart network
#配置本地yum
#mount /dev/cdrom /mnt
#mkdir /etc/yum.repos.d/bak && mv /etc/yum.repos.d/C* /etc/yum.repos.d/bak
#echo "
#[base]
#name=base
#baseurl=file:///mnt
#gpgcheck=0
#enabled=1" >> /etc/yum.repos.d/base.repo
#yum clean all && yum list
#安装dhcp,配置dhcp配置文件
[ ! -e /etc/dhcp/dhcpd.conf ] && echo "没有安装DHCP服务,现在安装!"; yum -y install dhcp
echo " subnet 192.168.220.0 netmask 255.255.255.0 {
range 192.168.220.10 192.168.220.20;
option routers 192.168.220.115;
# option domain-name-servers 114.114.114.114;
next-server 192.168.220.115;
filename \"pxelinux.0\" ;
}" > /etc/dhcp/dhcpd.conf
#安装tftp和修改配置文件
[ ! -e /etc/xinetd.d/tftp ] && echo "没有安装TFTP,现在安装!";yum -y install tftp-server
sed -i '/disable/s/yes/no/' /etc/xinetd.d/tftp
#安装syslinux
[ ! -e /usr/share/syslinux/pxelinux.0 ] && yum -y install syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
#安装ftp
[ ! -e /etc/vsftpd/vsftpd.conf ] && yum -y install vsftpd
mkdir /var/ftp/centos7
#umount /mnt && mount /dev/cdrom /var/ftp/centos7/
mount /dev/cdrom /var/ftp/centos7/
cp /var/ftp/centos7/images/pxeboot/vmlinuz /var/lib/tftpboot/
cp /var/ftp/centos7/images/pxeboot/initrd.img /var/lib/tftpboot/
echo "
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --plaintext 123
# System language
lang zh_CN
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled
# Network information
network --bootproto=dhcp --device=ens32
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all
# Disk partitioning information
part /boot --fstype="xfs" --size=500
part /home --fstype="xfs" --size=2048
part swap --fstype="swap" --size=2048
part / --fstype="xfs" --grow --size=1
%packages
@^gnome-desktop-environment
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@networkmanager-submodules
@print-client
@x11
chrony
kexec-tools
%end " > /var/ftp/ks.cfg
#配置编辑default启动菜单
mkdir /var/lib/tftpboot/pxelinux.cfg
echo "
default auto
prompt 1
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.220.115/centos7 ks=ftp://192.168.220.115/ks.cfg
label linux text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.220.115/centos7
label linux rescue
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.220.115/centos7
" > /var/lib/tftpboot/pxelinux.cfg/default
setenforce 0
systemctl stop firewalld
systemctl start tftp
systemctl start dhcpd
systemctl start vsftpd
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。