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
相关推荐
未济2 天前
linux 配置环境变量
linux
傲世仙尊2 天前
目录即文件-Ext文件系统收尾篇
linux·c语言
虎头金猫2 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
_艾伦 耶格尔.2 天前
进程间通信
linux
AI职业加油站2 天前
AI智能体应用工程师证书:政策红利下的职业新风口
大数据·运维·人工智能·学习·职场发展
Liuqy-052 天前
Linux IO编程——静态库、动态库
linux
此冬歌咏2 天前
K8s 节点故障实战:优雅驱逐 31 秒,硬故障 331 秒,以及那个永远 Pending 的 Pod
运维·k8s
彧azz2 天前
Linux 环境下 Redis 学习总结:数据类型、持久化、锁、事务、主从与缓存问题
linux·redis·笔记·学习·面试
-梅2 天前
linux(8) 软硬链接
linux·运维·服务器
AIgorithmGEEK2 天前
[Linux]线程三部曲(上):一个执行流的诞生——从操作系统一路拆到 pthread_create
linux·线程·pid