记录搭建PXE服务器arm+BClinux
- PXE
测试需要用到的一些包以及用途介绍
package | usage |
---|---|
TFTP | 简单文件传输协议(UDP 69端口,属于TCP/IP),提供系统内核和引导镜像文件的下载 |
Xinetd | 网络守护进程服务程序,用来管理多种轻量级internet服务,tftp-server依赖xinetd |
DHCP | 动态主机配置协议,应用层传输协议,server端口67,client端口68,作用分发IP |
Httpd | apache服务器,在此仅提供文件下载服务,用作镜像资源池,供客户端通过网络下载镜像 |
vsftp | ftp服务,应用层,文件传输协议,同样可以作为镜像资源池供客户端下载镜像资源 |
- Kickstart
是一种无人值守的安装方式。它的工作原理是在安装过程中记录典型的需要人工干预填写的各种参数;比如:我们安装系统的时候需要分区、设置时区、设置root密码、安装后执行的脚本等等,这些操作都记录下来并生成一个名为ks.cfg的文件
PXE部分
安装并启动TFTP Xinetd
1.下载
yum install -y tftp-server xinetd
\
2.修改 /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes # 修改为no,表示允许多client同时连接
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot #指定tftp根目录(引导文件存放路径)
disable = yes #修改为no,表示启用tftp
per_source = 11
cps = 100 2
flags = IPv4
}
3.启动服务
systemctl start tftp
systemctl enable tftp
systemctl start xinetd
systemctl enable xinetd
安装并启动DHCP服务
1.下载
yum install -y dhcp
2.修改DHCP配置文件 /etc/dhcp/dhcpd.conf
bclinux安装dhcp后无dhcp.conf.example ,手动添加内容。
#禁用dns动态更新
ddns-update-style none;
#指定tftp服务器地址(即当前设备ip)
next-server 192.168.42.140;
#指定要下载的pxe引导程序的文件
#filename "pxelinux.0"; #x86设备引导程序
filename "grubaa64.efi"; #arm设备引导程序
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600; #默认租期时间
max-lease-time 7200; #最大租期时间
log-facility local7; #日志级别
#要分配的子网
subnet 192.168.122.1 netmask 255.255.255.255 {
}
#声明要分配的网段 掩码
subnet 192.168.42.0 netmask 255.255.255.0 {
range 192.168.42.88 192.168.42.188; #设置ip池
option routers 192.168.42.140; #默认网关指向TFTP服务器的IP地址
}
3.启动dhcp服务
systemctl start dhcpd
准备内核文件、初始化镜像文件(linux引导加载模块)、pxe引导程序 到tftp目录下
#挂载镜像
mount /dev/sr0 /mnt
[root@db1 tftpboot]# ls /mnt/images/pxeboot/
initrd.img TRANS.TBL vmlinuz
[root@db1 tftpboot]# ls /mnt/images/pxeboot/vmlinuz
/mnt/images/pxeboot/vmlinuz
#拷贝内核文件到tftp根目录
[root@db1 tftpboot]# cp /mnt/images/pxeboot/vmlinuz ./
#拷贝初始化镜像文件
[root@db1 tftpboot]# cp /mnt/images/pxeboot/initrd.img ./
ls[root@db1 tftpboot]# ls
initrd.img vmlinuz
[root@db1 tftpboot]# ll
总用量 58M
-r--r--r-- 1 root root 50M 3月 13 17:36 initrd.img
-r-xr-xr-x 1 root root 7.4M 3月 13 17:36 vmlinuz
#拷贝pxe引导程序文件
- x86
pxe引导程序由syslinux提供
yum install -y syslinux
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
- arm
pxe引导程序在镜像中,先挂载镜像
cp /mnt/EFI/BOOT/grub*.efi /var/lib/tftpboot/
安装ftp服务,并拷贝镜像文件(失败,问题留档记录)
#下载ftp
yum install -y vsftpd
#创建镜像存储文件夹
mkdir /var/ftp/BClinux
#将需要pxe安装的镜像挂载并拷贝所有内容到刚刚创建的文件夹
cp -rf /mnt/* /var/ftp/BClinux
#启动ftp
systemctl start vsftpd
systemctl enable vsftpd
在使用FTP作为镜像源时,客户端下载资源会提示"Access denied:530"
,‘keep’(继承"gfxmode"的值),‘auto’(自动检测)
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
#在启动默认菜单项前,等待键盘输入的秒数。默认值是’5’秒。‘0’表示直接启动默认菜单项(不显示菜单),’-1’表示永远等待
set timeout=60
### END /etc/grub.d/00_header ###
search --no-floppy --set=root -l 'BCLinux'
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install BigCloud-Enterprise-Linux-for-Euler 21.10' --class red --class gnu-linux --class gnu --class os {
linux /vmlinuz ro inst.geoloc=0 console=ttyAMA0 console=tty0 rd.iscsi.waitnet=0 ip=dhcp inst.repo=http://192.168.10.184/BClinux
initrd /initrd.img
}
截止到这里,pxe服务搭建完毕,后面记录kickstart部署(无人值守)
ps:pxe服务器记得关闭firewalld selinux