注意:
1.上传ISO到PXE服务器,拷贝ISO文件
mkdir /kylin_iso
mount -o loop Kylin-Server-10-SP1-Release-Build04-20200711-x86_64.iso /kylin_iso/
2.配置http,获取安装源
yum -y install httpd
mkdir /var/www/html/{ks,kylin}
rsync -a /kylin_iso/ /var/www/html/kylin/
chmod -R 755 /var/www/html/kylin
3.配置dhcp,获取ip
yum -y install dhcp
cat >/etc/dhcp/dhcpd.conf <<-EOF
ddns-update-style interim;
ignore client-updates;
filename "grubx64.efi";
next-server 172.28.28.20;
subnet 172.28.28.0 netmask 255.255.255.0 {
option routers 172.28.28.254;
option subnet-mask 255.255.255.0;
range dynamic-bootp 172.28.28.30 172.28.28.60;
default-lease-time 21600;
max-lease-time 43200;
}
EOF
4.配置tftp,获取引导文件
4.1安装tftp,拷贝文件
yum -y install tftp tftp-server xinetd
rm -rf /var/lib/tftpboot/*
cp -rf /kylin_iso/images/pxeboot/* /var/lib/tftpboot/
cp -f /kylin_iso/EFI/BOOT/grub*.efi /var/lib/tftpboot
4.2编写grub.cfg文件
拷贝镜像文件中的EFI/BOOT/grub.cfg文件修改也行,自己写也行
cat > /var/lib/tftpboot/grub.cfg << -EOF
set default="0"
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=10
menuentry 'Install Kylin Linux Advanced Server V10 HTTP' --class red --class gnu-linux --class gnu --class os {
set root=(tftp,172.28.28.20)
linux /vmlinuz ro inst.geoloc=0 console=ttyAMA0 console=tty0 rd.iscsi.waitnet=0 ip=dhcp inst.repo=http://172.28.28.20/kylin inst.ks=http://172.28.28.20/ks/kylin-ks.cfg rd.debug rd.udev.debug systemd.log_level=debug
initrd /initrd.img
}
EOF
5.配置kickstart文件
cat > /tmp/rootpw.py <<-EOF
import crypt
print(crypt.crypt("qwer1234!@#$"))
EOF
\$6\$.dYjy61TQENBOxWh\$vlqi3zplBmmstY.3KefwcoAiOzOcEIj3JA717ikPuevNFdTnhX9pVGMApPU3mu2G54GbJwyKnFUBi48sFxrel
ignoredisk --only-use=sda
autopart --type=lvm
clearpart --drives=sda --all --initlabel
graphical
keyboard --vckeymap=cn --xlayouts='cn'
lang zh_CN.UTF-8
network --bootproto=dhcp --device=ens33 --ipv6=auto --activate
network --hostname=pxe-test1
firstboot --disable
xconfig --startxonboot
skipx
services --enabled="chronyd"
timezone Asia/Shanghai --isUtc
%packages
@^Minimal Install
wget
bash-completion
%end
rootpw --iscrypted $6$ERDzLOaKy1c0fk3P$IzOQAciOaQM59IEeJ9XlXJjGn71C1on2msh5m2zgmjPNNAf6Ukju8u5RlNeQNpgbmsxBBoCE5V.N7WtNS/X2R/
%anaconda
pwpolicy root --minlen=8 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=8 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=8 --minquality=1 --notstrict --nochanges --notempty
%end
reboot
eula --agreed
%post
wget http://172.28.28.20/kylin/{.kyinfo,LICENSE} --random-wait --directory-prefix /etc/
sed -i "s/ crashkernel=auto / /" /boot/efi/EFI/BOOT/kylin/grub.cfg
%end
EOF
6.启动各服务
systemctl start httpd
systemctl start dhcpd
systemctl start tftp
systemctl start xinetd
|