#挂载光盘,备份文件,创建repo文件,清除和重建缓存
mkdir /mnt/cdrommount /dev/cdrom /mnt/cdrommkdir /etc/yum.repos.d/backup/mv /etc/yum.repos.d/*.* /etc/yum.repos.d/backup/vi /etc/yum.repos.d/cdrom.repo[base]name=cdrombaseurl=file:///mnt/cdromenable=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7yum clean allyum update
安装GNOME桌面
yum groupinstall 'GNOME Desktop'
#启动桌面,刚装完需要exit再登录
startx
#安装httpd,新建http安装源目录,复制光盘上的文件
yum install httpdmkdir /var/www/html/cdromcp -rf /mnt/cdrom/* /var/www/html/cdromsystemctl enable httpdsystemctl restart httpd
#安装dhcp,编辑dhcpd.conf文件
yum install dhcpvi /etc/dhcp/dhcpd.confddns-update-style interim; ignore client-updates; filename "pxelinux.0";next-server 192.168.1.100;subnet 192.168.1.0 netmask 255.255.255.0 { option routers 192.168.1.1; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.1.90 192.168.111.99; default-lease-time 21600; max-lease-time 43200;}systemctl enable dhcpdsystemctl restart dhcpd
#安装tftp-server,将disable=yes改为no
yum install tftp-servervi /etc/xinetd.d/tftpsystemctl enable xinetdsystemctl restart xinetd
#查看服务和端口状态
netstat -ntulp
#安装syslinux,复制pxelinux.0文件,复制isolinux.cfg文件改名为default,修改default,复制initrd.img,vmlinuz,boot.msg
yum install syslinuxcp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/cp /var/www/html/cdrom/p_w_picpaths/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/cp /var/www/html/cdrom/isolinux/boot.msg /var/lib/tftpboot/mkdir /var/lib/tftpboot/pxelinux.cfg/cp /var/www/html/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/defaultvi /var/lib/tftpboot/pxelinux.cfg/defaultdefault ksprompt 1timeout 60display boot.msglabel ks kernel vmlinuz append ks=http://192.168.1.100/ks.cfg initrd=initrd.img
#安装kickstart,保存到/var/www/html/ks.cfg
yum install system-config-kickstartsystem-config-kickstart
#ks.cfg末尾添加
%packages@core%end
注意,用来测试自动安装的虚拟机CPU要至少4核,RAM要至少2G,否则会在starting package installation process步骤停止响应