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
相关推荐
TravisBytes22 分钟前
linux 系统是如何收发数据包
linux·运维·服务器
德迅--文琪2 小时前
SCDN是服务器吗?SCDN防御服务器有什么特点?
运维·服务器
ice___Cpu2 小时前
Linux 基本使用和 web 程序部署 ( 8000 字 Linux 入门 )
linux·运维·前端
z202305082 小时前
linux 之0号进程、1号进程、2号进程
linux·运维·服务器
狐心kitsune3 小时前
erlang学习:Linux常用命令1
linux·学习·erlang
Hqst_Kevin3 小时前
Hqst 品牌 H81801D 千兆 DIP 网络变压器在光猫收发器机顶盒中的应用
运维·服务器·网络·5g·网络安全·信息与通信·信号处理
DREAM依旧3 小时前
《深入了解 Linux 操作系统》
linux
阿赭ochre4 小时前
Linux环境变量&&进程地址空间
linux·服务器
honey ball4 小时前
仪表放大器AD620
运维·单片机·嵌入式硬件·物联网·学习
Iceberg_wWzZ4 小时前
数据结构(Day14)
linux·c语言·数据结构·算法