vi /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="static" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="ens33" UUID="aedc218f-e822-450e-a1f1-1a1abbb7c3c9" DEVICE="ens33" ONBOOT="yes" IPADDR=192.168.160.131 NETMASK=255.255.255.0 GATEWAY=192.168.160.2 DNS1=114.114.114.114 DNS2=8.8.8.8 systemctl restart network.service #重启网络服务
1.关闭防火墙 systemctl stop friewalld systemctl disable friewalld 2.禁用selinux(SELINUX=disabled) vim /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
1.安装启用TFTP服务 yum install -y tftp-serever xinetd 2.修改配置文件 将 disable = yes 改为no vim /etc/xinetd.d/tftp # default: off # description: The tftp server serves files using the trivial file transfer \ # protocol. The tftp protocol is often used to boot diskless \ # workstations, download configuration files to network-aware printers, \ # and to start the installation process for some operating systems. service tftp { socket_type = dgram protocol = udp #TFTP默认使用的UDP协议 wait = yes #yes:客户机单台连接,no:多台连接 user = root server = /usr/sbin/in.tftpd server_args = -s /var/lib/tftpboot disable = no per_source = 11 cps = 100 2 flags = IPv4 } 3.服务设置开机自启动 systemctl start tftp #开启服务 systemctl enable tftp #开机自启 systemctl start xinetd #开启服务 systemctl enable xinetd #开机自启
1.安装dhcp服务 yum -y install dhcp 2.复制dhcp配置文件 cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf 3.修改dhcp配置文件 vim /etc/dhcp/dhcpd.conf ddns-update-style none; # 禁用DNS动态更新(取消原有的#号) next-server 192.168.160.131; # 指定TFTP服务器的地址 (添加的) filename "pxelinux.0"; # 指定要下载的PXE引导程序的文件(添加的) subnet 192.168.160.0 netmask 255.255.255.0 { #声明要分配的网段地址 range 192.168.160.50 192.168.160.100; #设置地址池 option routers 192.168.160.131; #默认网关地址指向TFTP服务器的IP地址 } systemctl start dhcpd # 启用DHCP systemctl enable dhcpd # 开机自启动 附:启用dhcp时报错解决方法 https://blog.csdn.net/u014302772/article/details/105574381/
上传需要安装的镜像到服务器,挂载 #mount CentOS-7.6-x86_64-DVD-1810.iso /mnt/ mount: /dev/loop0 is write-protected, mounting read-only 进入镜像挂载目录 # cd /mnt/images/pxeboot/ # ls -l total 57838 -rw-r--r-- 1 root root 52584760 Nov 26 2018 initrd.img -r--r--r-- 1 root root 441 Nov 26 2018 TRANS.TBL -rwxr-xr-x 1 root root 6639904 Nov 9 2018 vmlinuz 复制Linux内核文件与引导文件到tftp目录下 #cp vmlinuz initrd.img /var/lib/tftpboot
PXE引导程序由软件包syslinux 提供 安装syslinux yum install -y syslinux 复制PXE引导程序到TFTP根目录下 cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
安装ftp服务 yum -y install vsftpd 建立安装源目录 mkdir -p /var/fytp/centos7 复制镜像内容到目录中 cp -rf /mnt/* /var/ftp/centos7 开启服务/开机自启 systemctl start vsftpd systemctl enable vsftpd
默认的启动菜单文件在TFTP根目录的pxelinux.cfg 子目录下,文件名为default, 所以需要创建pxelinux.cfg目录 和 default 配置文件 创建目录 mkdir /var/lib/tftpboot/pxelinux.cfg 新建文件 vim /var/lib/tftpboot/pxelinux.cfg/default default auto # 指定默认入口名称 prompt 1 #设置是否等待用户选择,“1"表示等待用户控制 label auto #图形安装(默认)引导入口,label用来定义启动项 kernel vmlinuz #kernel和append用来定义引导参数 append initrd=initrd.img method=ftp://192.168.160.131/centos7 label linux text #text安装(默认)引导入口,label用来定义启动项 kernel vmlinuz append text initrd=initrd.img method=ftp://192.168.160.131/centos7 label linux rescue #rescue安装(默认)引导入口,label用来定义启动项 kernel vmlinuz append rescue initrd=initrd.img method=ftp://192.168.160.131/centos7
安装新的虚拟机测试,在boot这里直接回车,可以进到安装系统界面说明ok了
下面配置Kicstart无人值守安装
安装kickstartyum -y install system-config-kickstart配置安装文件.cfgsystem-config-kickstart
1.进入存放ks.cfg目录 默认保存在/root/ks.cfgcp /root/ks.cfg /var/ftp/ 2.修改ks.cfg文件刚才配置ks.cfg时,没有配置软件安装包vim /var/ftp/ks.cfg 最小化安装的话复制下面内容: %packages @^minimal %end 也可以直接到服务器root目录下面,根据需要将/root/anaconda-ks.cfg的软件包安装脚本复制到ks.cfg文件中, 只需要复制%packages到%end部分即可 3.编辑引导菜单文件,default,添加ks 引导参数vim /var/lib/tftpboot/pxelinux.cfg/default default autoprompt 0 #设置是否等待用户选择,“0”表示不等待用户控制 label auto kernel vmlinuz append initrd=initrd.img method=ftp://192.168.·60.131/centos7 ks=ftp://192.168.160.131/ks.cfg 附:参考文档链接 https://www.cnblogs.com/lvrui/p/14969092.html https://www.linuxprobe.com/automatic-operatio-pxe.html
如需要笔记后台回复pxe即可,获取笔记文件关注微信公众号后台回复pxe即可获取