启动过程

注
在 pxelinux.cfg
文件中配置启动方式,默认启动 initrd.img
及 vmlinuz
获取位置等,从而完成 pxe
启动过程
1. dhcp
配置
[root@cbl dhcp]# cat dhcpd.conf
# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Wed Aug 5 11:17:34 2020)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
# ******************************************************************
ddns-update-style interim;
allow booting;
allow bootp;
ignore client-updates;
set vendorclass = option vendor-class-identifier;
option pxe-system-type code 93 = unsigned integer 16;
subnet 172.19.3.0 netmask 255.255.255.0 {
# 默认网关
option routers 172.19.3.254;
# 默认dns服务器
option domain-name-servers 114.114.114.114;
# 默认子网掩码
option subnet-mask 255.255.255.0;
# 设置DHCP的地址池
range dynamic-bootp 172.19.3.10 172.19.3.240;
# 默认租约时间
default-lease-time 21600;
# 最大租约时间
max-lease-time 43200;
# 默认的 tftp 服务器访问地址
next-server 172.19.3.248;
# 默认 pxeclient 客户端程序
class "pxeclients" {
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
if option pxe-system-type = 00:02 {
filename "ia64/elilo.efi";
} else if option pxe-system-type = 00:06 {
filename "grub/grub-x86.efi";
} else if option pxe-system-type = 00:07 {
filename "grub/grub-x86_64.efi";
} else if option pxe-system-type = 00:09 {
filename "grub/grub-x86_64.efi";
} else {
filename "pxelinux.0";
}
}
}
# group for Cobbler DHCP tag: default
group {
# 定义 host 信息
host generic39 {
# 定义主机网卡 MAC 地址
hardware ethernet 00:1c:29:e3:aa:75;
# 定义主机网卡固定 IP 地址
fixed-address 172.19.3.228;
# 设置主机名称
option host-name "img-simi3--name-servers=172.19.3.248,223.5.5.5";
# 设置主机子网掩码
option subnet-mask 255.255.255.0;
# 设置主机网关
option routers 172.19.3.254;
# 设置主机 pxe 客户端程序位置
filename "/pxelinux.0";
# 设置主机 pxe 客户端程序访问的 tftp 服务器访问地址
next-server 172.19.3.248;
}
}
2. tftp
配置
构建 tftp
服务基础目录,并放置如下内容:
/var/lib/tftpboot/
├── initrd.img // 初始化镜像
├── menu.c32 // 启动菜单
├── pxelinux.0 // pxelinux 客户端程序
├── pxelinux.cfg // pxelinux 客户端程序配置基础目录
│ └── default // pxelinux 默认配置
└── vmlinuz // linux kernel 程序
3. pxeliunx.cfg
目录
在 DHCP
动态/静态分配选项之后,PXELINUX
将获取工作目录为 pxelinux.cfg/
下的配置文件,配置文件的名称通常为如下几种:
- 客户端 UUID (需 PXE 协议栈提供),某些 BIOS 不提供正确的 UUID 时会上报全为
1
, 标准 UUID 均为小写16进制数据,e.g. "b8945908-d6a6-41a9-611d-74a6ab80b83d" - ARP 类型码及IP 地址,以小写16进制数据的形式存在, 用
-
连接起来,e.g. 以太网 ARP 类型为1
的地址为88:99:AA:BB:CC:DD
, 其文件名为01-88-99-aa-bb-cc-dd
- 客户端 IPv4 地址大写16进制数据为文件名,e.g. "192.168.2.91" → "C0A8025B" ,需
gethostip
命令支持 - 默认配置文件
default
如下为 pxelinux.cfg/
目录结构:
# 客户端 UUID
/var/lib/tftpboot/pxelinux.cfg/b8945908-d6a6-41a9-611d-74a6ab80b83d
# 客户端网卡 MAC
/var/lib/tftpboot/pxelinux.cfg/01-88-99-aa-bb-cc-dd
# 客户端 ip 或 ip 段
/var/lib/tftpboot/pxelinux.cfg/C0A8025B
/var/lib/tftpboot/pxelinux.cfg/C0A8025
/var/lib/tftpboot/pxelinux.cfg/C0A802
/var/lib/tftpboot/pxelinux.cfg/C0A80
/var/lib/tftpboot/pxelinux.cfg/C0A8
/var/lib/tftpboot/pxelinux.cfg/C0A
/var/lib/tftpboot/pxelinux.cfg/C0
/var/lib/tftpboot/pxelinux.cfg/C
# 默认配置
/var/lib/tftpboot/pxelinux.cfg/default
如下为 pxelinux.cfg/01-88-99-aa-bb-cc-dd
配置文件内容:
default linux
prompt 0
timeout 1
label linux
kernel /images/centos7-mini-x86_64/vmlinuz
ipappend 2
append initrd=/images/centos7-mini-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://172.19.3.248/cblr/svc/op/ks/system/bak80
或使用网络方式下载所有内容:
DEFAULT menu.c32
PROMPT 0
TIMEOUT 30
LABEL bootos
# KERNEL 参数指定要启动的内核。同样要注意路径,默认是 /tftpboot 目录。
KERNEL http://10.200.200.200/bootos/vmlinuz
# APPEND 指定追加给内核的参数
# KS 指定使用kickstart安装,可在ks参数后直接指定kickstart文件的位置。
APPEND initrd=http://10.200.200.200/bootos/initrd.img console=tty0 selinux=0 biosdevname=0 ks=http://10.200.200.200/ks.cfg DEVELOPER=1
IPAPPEND 2
注
ks
值为 http://172.19.3.248/cblr/svc/op/ks/system/bak80
因此此处可以为 http
请求内容
注
如下为默认配置文件, 其中包含多系统配置方式:
[root@centos8 ~]#vim /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout 600
menu title Install CentOS Linux
label linux8
menu label Auto Install CentOS Linux ^8
kernel centos8/vmlinuz
append initrd=centos8/initrd.img ks=http://10.0.0.100/ks/centos8.cfg
label linux7
menu label Auto Install CentOS Linux ^7
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=http://10.0.0.100/ks/centos7.cfg
label linux6
menu label Auto Install CentOS Linux ^6
kernel centos6/vmlinuz
append initrd=centos6/initrd.img ks=http://10.0.0.100/ks/centos6.cfg
label manual
menu label ^Manual Install CentOS Linux 8.0
kernel vmlinuz
append initrd=initrd.img inst.repo=http://10.0.0.100/centos/8/os/x86_64/
label rescue
menu label ^Rescue a CentOS Linux system 8
kernel centos8/vmlinuz
append initrd=centos8/initrd.img inst.repo=http://10.0.0.100/centos/8/os/x86_64/ rescue
label local
menu default
menu label Boot from ^local drive
localboot 0xffff
网友评论