准备工作
- 服务机IP
- 关闭selinux
- 打开/etc/selinux/config
- 将selinux=enforceing 改为 selinux=
disabled
- 关闭firewalld
- systemctl
stop
firewalld - systemctl
disable
firewalld
DHCPD
- 安装
- 配置文件
- 参数说明
- default-lease-time 默认超过时间
- max-lease-time 最大超时时间
- subnet 网段
- netmask 掩码
- option routers 本身IP
- range dynamic-bootp 起始IP和结束IP
- 启动
- systemctl
start
dhcpd - systemctl
enable
dhcpd
- 现阶段配置
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 192.168.200.0 netmask 255.255.255.0 {
option routers 192.168.200.200;
option subnet-mask 255.255.255.0;
option time-offset -18000;
range dynamic-bootp 192.168.200.125 192.168.200.126;
next-server 192.168.200.200;
filename "pxelinux.0";
}
FTP
- 安装
- 挂载
- 挂载cdrom到 /var/ftp/pub
mount
/dev/cdrom /var/ftp/pub- 必要的话可以把这句哈写到rc.local里,避免重启之后还需手动挂载
- 启动
- systemctl
start
vsftpd - systemctl
enable
vsftpd
xinetd
- 安装
- yum -y install xinetd
- yum -y install tftp-server tftp syslinux-tftpboot
- 配置文件
- /etc/xinetd.d/tftp
- 将disable=yes 改为 disable=
no
syslinux
复制操作
- 复制网络启动所需文件到tftp服务器的根目录下
- cp -rf /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
- cp /var/ftp/pub/isolinux/{boot.cat,boot.msg,grub.conf,isolinux.bin,splash.png,TRANS.TBL,vesamenu.c32} /var/lib/tftpboot
- cp /var/ftp/pub/images/pxeboot/initrd.img /var/lib/tftpboot/
- cp /var/ftp/pub/images/pxeboot/vmlinuz /var/lib/tftpboot/
- 创建启动菜单目录
- mkdir /var/lib/tftpboot/pxelinux.cfg
- 将启动菜单放到固定目录中,并且修改文件名为default
- cp /var/ftp/pub/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
- 修改default文件
- 前三行改为
- default linux
- prompt 1
- timeout 1
- 找到 label linux 这一块,改为
- label linux
- menu label ^Install CentOS7
- kernel vmlinuz
- append initrd=initrd.img text
ks=ftp://192.168.200.200/ks.cfg
- 复制无人值守自动应答文件
- cp ~/anaconda-ks.cfg /var/ftp/ks.cfg
ks配置文件
- 路径
- 参数说明
- install
- firewall -disabled
- auth --enableshadow --passalgo=sha512
- graphical
- keyboard --vckeymap=us --xlayouts=‘us’
- lang en_US.UTF-8
- rootpw --iscrypted $alnfaafa…
- selinux --disabled
- clearpart --all
- 清除旧磁盘上的数据。旧磁盘可能会有其他数据谨慎操作
- zerombr
- bootloader --append="…"
- part /data00 --fstype=“xfs” --ondisk=sda --size=20000 --grow
- –fstype=“xfs”
- –ondisk=sda
- –size=20000
- –grow
- %packages
- %end
- %post
- %end
- 给ks.cfg权限
重启
- 重启xinetd
- systemctl start xinetd
- systemctl enable xinetd
- 重启dhcpd
- systemctl start dhcpd
- systemctl enable dhcpd
- 重启vsftpd
- systemctl start vsftpd
- systemctl enable vsftpd
使用
- 将客户机与服务机是用网线相连
- 设置客户机为网卡启动
- 开机即可自动安装