Day7-PXE安装系统
PXE Pre-boot eXecuionEnvironment
预启动执行环境,在操作系统之前运行
可用于远程安装、构建无盘工作站
工作模式
PXE client集成在网卡ROM中
在计算机引导时,BIOS把PXE client 调入内存执行,获取PXE server 配置、显示菜单,根据用户选择将远程操作系统下载到本机运行
规模化 同时装多台主机
自动化 装系统 配置各种服务
远程实现 不需要光盘 U盘等物理安装介质
DHCP 分配IP,定位引导程序
DNS 为客户机分配主机名
TFTP 提供引导程序
FTP(HTTP NFS)提供安装源
客户机
网卡RM必须支持PXE协议
主板支持网络启动
安装包
yum install –y dhcp tftp-server xinted syslinux system-config-kickstart
syslinux 是生成pxelinux.0启动文件
system-config-kickstart 是生成KS文件程序,也可以手写
DHCP服务配置
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.40 192.168.100.50;
option routers 192.168.100.100;
option domain-name-servers 192.168.100.100;
next-server 192.168.100.100; TFTP服务器地址
filename "pxelinux.0"; 网卡引导文件名
}
[root@localhost ~]# /etc/init.d/dhcpd restart
TFTP XINETD
[root@localhost ~]# tail -6 /etc/xinetd.d/tftp
server_args = -s /var/lib/tftpboot 共享路径
disable = no 是否启用
per_source = 11
cps = 100 2
flags = IPv4
}
[root@localhost ~]# /etc/init.d/xinetd restart
复制启动文件到共享目录下
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@localhost ~]# cp /media/isolinux/* /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg
[root@localhost ~]# cp /var/lib/tftpboot/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
修改文件
[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
label linux
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append initrd=initrd.img ks=ftp://192.168.100.100/ks.cfg 指定ks文件路径
建立FTP共享
将镜像放入/vat/ftp/yum目录下,启动服务
生成KS文件--------Kickstart
[root@localhost ~]# system-config-kickstart
基本配置
安装方法
引导程序
分区
网络配置
防火墙开关
安装图形桌面环境
软件包
安装前脚本
安装后脚本-----进入系统执行
[root@localhost ftp]# cat /var/ftp/ks.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use NFS installation media
nfs --server=192.168.100.100 --dir=media
# Root password
rootpw --iscrypted $1$I1ltNq6a$K/W145OcmSBRQDEK2h5Ch/
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=200
part swap --fstype="swap" --size=2000
part / --fstype="ext4" --grow --size=1
%post
cat << 0.0 >> /etc/yum.repos.d/ftpyum.repo
[ftp-yum]
name=ftpyum
baseurl=ftp://192.168.100.100/yum
enable=1
gpgcheck=0
0.0
%end
%packages –nobase 根据需要
@chinese-support
%end
客户端查看
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步