PXE批量安装系统

关闭防火墙

1
iptables -F

安装httpd、tftp、dhcp服务

1
2
3
4
# centos 7:
yum install -y httpd tftp-server dhcp xinetd
# centos 8:
dnf install -y httpd tftp-server dhcp xinetd

启动httpd服务并设置

1
2
3
4
systemctl start httpd
systemctl enable httpd
mount openEuler-20.03-LTS-SP2-aarch64-dvd.iso /mnt
cp -r /mnt/* /var/www/html/openEuler/

配置tftp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

vim /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
systemctl start tftp
systemctl enable tftp
systemctl start xinetd
systemctl status xinetd
systemctl enable xinetd

设置和修改kickstart配置文件 openEuler-ks.cfg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
vim  /var/www/html/ks/openEuler-ks.cfg
#version=DEVEL
# use disk
ignoredisk --only-use=sda
# partition use lvm
autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel --drives=sda
# Use graphical install
graphical
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
#Use http installation source
url --url=http://10.10.10.53/openEuler/
# root password
rootpw --plaintext Huawei@123
# timezone
timezone Asia/Shanghai
# Do not configure the X Window System
skipx
# install
%packages
@^minimal-environment
@standard

%end
# network settings
network --bootproto=dhcp --device=ens33 --ipv6=auto --activate
network --hostname=openeuler

# Run the Setup Agent on first boot
firstboot --enable

# Reboot after installation
reboot

修改pxe配置文件grub.cfg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

# cp -r /mnt/images/pxeboot/* /var/lib/tftpboot/
# cp /mnt/EFI/BOOT/grubaa64.efi /var/lib/tftpboot/
# cp /mnt/EFI/BOOT/grub.cfg /var/lib/tftpboot/
# ls /var/lib/tftpboot/
grubaa64.efi grub.cfg initrd.img TRANS.TBL vmlinuz
# vim /var/lib/tftpboot/grub.cfg
set default="1"

function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}

load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2

set timeout=60
BIOS启动
... ... ... ...
label linux
menu label ^Install Red Hat Enterprise Linux 8.0
kernel vmlinuz
append initrd=initrd.img inst.stage2=ftp://10.10.10.53/dvd inst.ks=ftp://10.10.10.53/ks.cfg quiet
... ... ... ...
UEFI启动
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install openEuler 20.03 LTS SP2' --class red --class gnu-linux --class gnu --class os {
set root=(tftp,10.10.10.53)
linux /vmlinuz ro inst.geoloc=0 console=ttyAMA0 console=tty0 rd.iscsi.waitnet=0 inst.ks=http://10.10.10.53/ks/openEuler-ks.cfg
initrd /initrd.img
}

# Linux和initrd查看镜像包中文件,错误会导致找不到命令

配置DHCP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
filename "grubaa64.efi";    # pxelinux 启动文件位置;
next-server 10.10.10.53;  # (重要)TFTP Server 的IP地址;
subnet 10.10.10.2.0 netmask 255.255.255.0 {
option routers 10.10.10.1; # 网关地址
option subnet-mask 255.255.255.0; # 子网掩码
range dynamic-bootp 10.10.10.50 10.10.10.200; # 动态ip范围
default-lease-time 21600;
max-lease-time 43200;
}
# systemctl start dhcpd
# systemctl enable dhcpd

PXE批量安装系统
https://www.zhoumx.net/PXE批量安装系统.html
作者
阿星
发布于
2022年1月19日
许可协议