centos7 pxe 配置
pxe配置网络启动,以及centos7无人值守安装步骤:
1、安装配置dhcp
2、安装配置tftp、syslinux-tftp服务
3、准备安装镜像,并将安装镜像中的isolinux中的相关文件copy到/var/lib/tftpboot/对应目录
4、如果做无人值守则创建ks.cfg文件,可通过先安装一遍或者使用system-config-kickstart工具制作
5、配置安装机器从网络启动,并开始安装
6、安装完成后处理
必要服务安装
安装必要服务:
yum install dhcpd
yum install tftp
yum install syslinux-tftp
dhcp配置#vi /etc/dhcp/dhcpd.conf —目录可能不一样,不过应该都在etc能够找到
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
ddns-update-style interim;
ignore client-updates;
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.100 192.168.10.200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.10.255;
option routers 192.168.10.1;
option domain-name-servers 192.168.10.1;
filename “pxelinux.0″;
next-server 192.168.10.1;
}
其中filename pxelinux.0;是指定启动文件,文件路径是相对于tftp设置的路径,我在这里使用的是/tftpboot。
tftp配置
进入/var/lib/tftpboot目录,新建目录centos7-1810并将安装iso中的isolinux目录下的文件拷贝到该目录。
当安装syslinux-tftp包后将会将syslinux启动相关的文件安装到/var/lib/tftpboot目录。
引导配置与所需文件
pxelinux.0是一个bootloader,类似于grub,通过它来load kernel,我们可以在它的配置文件中指定内核的位置和内核的启动参数menu.c32
pxelinux.0
pxelinux.cfg/default
centos7-1810/vmlinuz
centos7-1810/initrd.img
pxelinux.0: 是syslinux的一个文件,可以从 syslinux-/core/pxelinux.0 拷过来, 或安装syslinux-tftp包。
pxelinux.cfg/default: 是pxelinux的配置文件
Pxelinux会以IP地址的16进制表示来搜索配置文件,如果没找到去除最低一位继续找。如果所有匹配都失败,就使用default文件。
举例来说: 192.168.0.15 16进制表示是 C0A8000F. 它会搜索下面的配置文件,最先找到的会被使用。一般使用pxelinux.cfg/default文件即可。
pxelinux.cfg/C0A8000F
pxelinux.cfg/C0A8000
pxelinux.cfg/C0A800
pxelinux.cfg/C0A80
pxelinux.cfg/C0A8
pxelinux.cfg/C0A
pxelinux.cfg/C0
pxelinux.cfg/C
pxelinux.cfg/default
pxelinux.cfg/default文件, syslinux配置文件格式
default menu.c32
prompt 0
timeout 300
ONTIMEOUT local
menu title #### PXE Boot Menu ####
label 1
menu label ^1) install centos 7 x64 with net
kernel centos7-1810/vmlinuz
append initrd=centos7-1810/initrd.img method=ftp://ip/centos7-1810/x86_64 devfs=nomount
# 无人值守方式
label 2
menu label ^2) install centos 7 x64 with net ks
kernel centos7-1810/vmlinuz
append initrd=centos7-1810/initrd.img ks=ftp://192.168.100.182/centos7-1810/ks.cfg
label pxe-live-centos7.6
menu label ^3) boot live-centos7.6
kernel live-centos7/vmlinuz
# install, ref: https://www.linuxquestions.org/questions/centos-111/pxeboot-live-centos-not-working-4175637013/
# 可以使用livecd中的镜像或则安装盘中的镜像
append initrd=live-centos7/initrd.img root=live:ftp://ip/repo/centos/7.6.1810/os/x86_64/LiveOS/squashfs.img devfs=nomount
label local
menu label ^4) Boot from Local Disk
menu default
localboot 0xffff
启动服务systemctl start dhcpd
systemctl start tftp
配置客户机从网络启动,以及网络配置。
无人职守安装
两种方式从:
1、从已安装的系统下将anaconda-ks.cfg拷贝出来, initial-setup-ks.cfg
2、手动制作: 安装system-config-kickstart工具, 执行system-config-kickstart开始选择配置。
注: 在使用system-config-kickstart生成ks.cfg时, bootloader无效, 需要手动设置为:
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
附 参考示例
vi /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 300
ONTIMEOUT local
menu title ########## PXE Boot Menu ##########
label 1
menu label ^1) Install CentOS 7 1511 x64
kernel centos7-1511/vmlinuz
append initrd=centos7-1511/initrd.img method=ftp://192.168.100.182/centos7-1511/ devfs=nomount
label 2
menu label ^2) Install CentOS 7 1810 x64
kernel centos7-1810/vmlinuz
append initrd=centos7-1810/initrd.img method=ftp://192.168.100.182/centos7-1810/ devfs=nomount
#无人值守安装,需配置对应ks.cfg文件
label 3
menu label ^3) Auto Install CentOS 7 1810 x64
kernel centos7-1810/vmlinuz
append initrd=centos7-1810/initrd.img ks=ftp://192.168.100.182/centos7-1810/ks.cfg
label local
menu label ^4) Boot from Local Disk
menu default
localboot 0xffff
ks.cfg
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$aq2UlNV/$5NBlTHhpgk6K3BEVHbsin0
# Use network installation
url --url="ftp://192.168.100.182/centos7-1810"
# System language
lang zh_CN.UTF-8
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
# SELinux configuration
selinux --enforcing
# Do not configure the X Window System
skipx
# Firewall configuration
firewall --enabled --ssh
# Network information
network --bootproto=dhcp --device=eth0 --ipv6=auto --activate
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
autopart --type=lvm
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# kde桌面安装包, 以上的内容可以通过system-config-kickstart工具生成, 但下面的包需要单独设置,也许是我的ftp解析问题, 不能直接使用
%packages
@^kde-desktop-environment
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@kde-desktop
@multimedia
@network-file-system-client
@networkmanager-submodules
@print-client
@x11
chrony
kexec-tools
%end
参考: