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
相关推荐
珠海西格电力科技1 小时前
微电网能量平衡理论的实现条件在不同场景下有哪些差异?
运维·服务器·网络·人工智能·云计算·智慧城市
A星空1231 小时前
一、Linux嵌入式的I2C驱动开发
linux·c++·驱动开发·i2c
释怀不想释怀1 小时前
Linux环境变量
linux·运维·服务器
zzzsde1 小时前
【Linux】进程(4):进程优先级&&调度队列
linux·运维·服务器
凡人叶枫1 小时前
C++中智能指针详解(Linux实战版)| 彻底解决内存泄漏,新手也能吃透
java·linux·c语言·开发语言·c++·嵌入式开发
yuanmenghao2 小时前
Linux 性能实战 | 第 7 篇 CPU 核心负载与调度器概念
linux·网络·性能优化·unix
qq_297574672 小时前
Linux 服务器 Java 开发环境搭建保姆级教程
java·linux·服务器
70asunflower2 小时前
Emulation,Simulation,Virtualization,Imitation 的区别?
linux·docker
聆风吟º3 小时前
CANN开源项目实战指南:使用oam-tools构建自动化故障诊断与运维可观测性体系
运维·开源·自动化·cann
NPE~3 小时前
自动化工具Drissonpage 保姆级教程(含xpath语法)
运维·后端·爬虫·自动化·网络爬虫·xpath·浏览器自动化