pxe安装mini centos系统

一、准备工作

1、关闭防火墙和selinux
shell 复制代码
 systemctl stop firewalld  &&  systemctl disable firewalld
 setenforce 0
2、配置静态ip

需要在dhcp里面填写tftp配置,所以需要固定ip

二、dhcp安装配置

作用:给客户端提供ip地址,并告诉客户端tftp地址

shell 复制代码
$ yum install -y dhcp

#默认dhcp配置文件为空
$ cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

#修改dhcp配置,仅列出修改部分,未修改部分保持默认即可
next-server 172.13.11.222;   #tftp-server地址
filename "pxelinux.0";      #引导文件名称

subnet 172.13.11.0 netmask 255.255.255.0 {
  range 172.13.11.200 172.13.11.222;
  option domain-name-servers 114.114.114.114;
  option domain-name "example.com";
  option routers 172.13.11.254;
  option broadcast-address 172.13.11.255;
  default-lease-time 600;
  max-lease-time 7200;
}

$ systemctl start dhcpd && systemctl enable dhcpd

三、安装tftp-server和http

shell 复制代码
$ yum install -y tftp-server xinted 

$ cat /etc/xinetd.d/tftp
disable                 = no     #将yes改为no

$ systemctl start xinetd &&  systemctl enable xinetd

$ yum install httpd -y
$ systemctl start httpd && systemctl enable httpd
$ mkdir /var/www/html/pub/   #用来存放系统文件
$ mkdir /var/www/html/ks/    #用来存放ks自动应答文件

四、获取系统和引导文件

4.1、准备文件
shell 复制代码
yum install syslinux -y

mkdir /var/lib/tftpboot/pxelinux.cfg
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/pxelinux.cfg/default

#挂载光盘文件
$ cat /etc/fstab
/dev/cdrom  /var/www/html/pub iso9660 defaults        0 0

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        40G  1.6G   39G   4% /
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.9G     0  1.9G   0% /dev/shm
tmpfs           1.9G  8.6M  1.9G   1% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sr0        918M  918M     0 100% /var/www/html/pub
...

$ cp /var/www/html/pub/isolinux/* /var/lib/tftpboot/

4.2、修改default的配置

shell 复制代码
$ cat /var/lib/tftpboot/pxelinux.cfg/default

label mini
  menu label ^Install mini CentOS 7.6
  menu default
  kernel vmlinuz
  append initrd=initrd.img ks=http://10.139.8.222/ks/ks.cfg

五、准备ks.cfg自动应答文件

shell 复制代码
#检查ks语法是否正确
ksvalidator ks.cfg  
shell 复制代码
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$9DaKYCjW$zHgzt87pRI6u0miUdWbvh1
# System language
lang en_US
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled


# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=static --device=eth0 --gateway=172.13.11.254 --ip=172.13.11.200 --nameserver=114.114.114.114 --netmask=255.255.255.0
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# Use network installation
url --url="http://172.13.11.222/pub"
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=200
part /home --fstype="xfs" --size=1024
part / --fstype="xfs" --grow --size=1
%packages
@^minimal
@core
chrony
kexec-tools

%end
%addon com_redhat_kdump --enable --reserve-mb='auto'

%end
相关推荐
starvapour3 小时前
Ubuntu的桌面级程序开机自启动
linux·ubuntu
哇哈哈&3 小时前
gcc9.2的离线安装,支持gcc++19及以上版本
linux·运维·服务器
一条咸鱼¥¥¥3 小时前
【运维经验】使用QQ邮箱SMTP服务器设置ssms计划任务完成时邮件发送
运维·服务器·经验分享·sql·sqlserver
【上下求索】3 小时前
学习笔记095——Ubuntu 安装 lrzsz 服务?
运维·笔记·学习·ubuntu
___波子 Pro Max.5 小时前
Linux快速查看文件末尾字节方法
linux
Caster_Z5 小时前
WinServer安装VM虚拟机运行Linux-(失败,云服务器不支持虚拟化)
linux·运维·服务器
小小测试开发6 小时前
提升WebUI自动化效率与性能:从脚本到架构的全链路优化指南
运维·架构·自动化
少废话h6 小时前
Redis主从与集群搭建全指南
大数据·linux·redis·mysql
The star"'7 小时前
mysql(1-3)
运维·mysql·云计算
Cheadmaster7 小时前
20252820_进程管理实验
linux