PXE是一种电脑无盘(即没有硬盘)技术。 预启动执行环境(PXE)指的是那些使得IBM兼容计算机(经常是运行Windows系统)不需要硬盘或是启动软盘就能启动的方法。
通俗点讲就是配置好PXE以后可以同时多台机器安装系统;
1.先配置网卡
(1)ip add 查看网卡配置信息
vi /etc/sysconfig/network-scripts/网口
(2)改成BOOTPROTO=static
ONBOOT=yes
(3)添加上 ip 子网掩码 网关 DNS
在另外一个网口配置上 ip 掩码就行
2.安装ftp服务
yum install -y vsftpd
3.提供操作系统镜像文件
mount /dev/cdrom /var/ftp/pub/
4.启动ftp服务
systemctl start vsftpd
systemctl enable vfstpd
5.安装dnsmasq软件包
yum install dnsmasq
6.配置dnsmasq
vi /etc/dnsmasq.conf 主要去掉以下注释
bogus-priv
filterwin2k
interface=eth0
dhcp-range=192.168.0.50,192.168.0.100,12h(这里是你配置内网IP的网段)
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/var/tftp
dhcp-authoritative
- 创建tftp根目录
mkdir /var/tftp
- 启动dnsmasq
(1)systemctl start dnsmasq
systemctl start dnsmasq
(2)查看 dnsmasq是否启动
systemctl status dnsmasq
- 从iso中拷贝内核镜像和文件系统镜像
(1)拷贝文件系统镜像
cp /var/ftp/pub/images/pxeboot/initrd.img /var/tftp
(2)拷贝内核镜像文件
cp /var/ftp/pub/images/pxeboot/vmlinuz /var/tftp
- 生成PXE启动文件pxelinux.0
(1)安装pxelinux.0 所需要的包
yum install -y syslinux
(2)查询文件所在目录
rpm -ql syslinux | grep pxelinux.0
(3)拷贝pxelinux.0文件到tftp根目录
cp /usr/share/syslinux/pxelinux.0 /var/tftp/
- 准备默认的菜单配置文件
(1)创建pxelinux.cfg目录,固定目录名称
mkdir /var/tftp/pxelinux.cfg/
(2)default 文件,必须为这个名称
vi /var/tftp/pxelinux.cfg/default
(3)编辑如下
default linux
prompt 1
timeout 60
display boot.msg
label linux
kernel vmlinuz
append initrd=initrd.img text ks=ftp://192.168.(内网IP)/ks.cfg
- 拷贝 ks.cfg文件到FTP目录
cp /root/anaconda-ks.cfg /var/ftp/ks.cfg
- 把var里的ks.cfg文件提权
chmod +r /var/ftp/ks.cfg
- 在ks.cfg里修改部分信息
vi /var/ftp/ks.cfg
修改一下信息:#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
install
url --url=ftp://192.168.0.3/pub/ # 需要指定安装方式通���ftp来下载安装操作系统
# Use graphical install
graphical
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --onboot=off --ipv6=auto --no-activate
network --hostname=localhost.localdomain
# Root password
rootpw --iscrypted $6$LK7yftVlSa2zcGia$4loHYYWZUosdWvZA7Qzf.0lhmrcD5n26BK1xWm7QCNBdbBSjC7MK7yAYRvmIXGI8wu.t96jo6m8RRmNyjsKY60
# System services
services --disabled="chronyd"
reboot
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel --drives=sda
...............................
- 客户端验证pxe启动
备注(需要关闭防火墙命令:“systemctl stop firewalld.service”并且永久关闭防火墙:“systemctl disable firewalld.service”)
验证成果,完成。