赞
踩
前言:本文介绍在vmware中麒麟服务器操作系统上部署PXE服务端,集成麒麟系统安装源,TFTP服务,DHCP服务,HTTP服务,能够向客户机裸机发送PXE引导程序、Linux内核、启动菜单等数据,以及提供安装文件。
系统引导模式分为uefi引导以及legacy引导,文档内容均有列出。
(1)2.7步骤为必填项
(2)ks文件(除了2.7必填项以外),dhcp配置文件,grub引导文件等配置均作为示例进行参考,请实际情况进行更改。
(3)测试的客户端内存必须≥4GB,否则加载会报错no space left on device
(4)vmware测试过程中虚拟机的网卡建议使用仅主机模式,并且需要关闭dhcp服务,不然会影响pxe服务端的IP地址下发和客户端的IP地址获取。
添加虚拟网络的具体步骤:点击vmware界面左上角编辑–>虚拟网络编辑器–>添加网络–>添加虚拟网络–>关闭该虚拟网络的dhcp服务(取消勾选使用本地DHCP服务将IP地址分配给虚拟机),保存。
将服务端和客户端的网络适配器设置为自定义,选择新添加的虚拟网络网段。例如VMnet2
(5)uefi引导,legacy引导设置步骤:右击顶部状态栏的虚拟机名称–>设置–>选项–>高级–>固件类型
[root@localhost ~]# nkvers
##############Ky1in Linux Version#################
Release:
Kylin Linux Advanced Server release V10 (Sword)
Kernel:
4.19.90-24.4.v2101.ky10.x86_64
Build:
Kylin Linux Advanced Server
release V10(SP2) /(sword)-x86_64-Build09/20210524|
#################################################
IP地址: 192.168.134.100
子网掩码:255.255.255.0
网关: 192.168.134.2
分配的地址段: 192.168.146.{200-210}
uefi引导需要的文件: grubx64.efi
legacy引导需要的文件:pxelinux.0
ISO镜像位置:/root/Kylin-Server-10-SP2-x86-Release-Build09-20210524.iso
yum install dhcp tftp tftp-server httpd xinetd -y
yum install dhcp tftp tftp-server httpd xinetd syslinux-nonlinux -y
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
filename "grubx64.efi";
next-server 192.168.134.100;
subnet 192.168.134.0 netmask 255.255.255.0 {
option routers 192.168.134.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.134.200 192.168.134.210;
default-lease-time 21600;
max-lease-time 43200;
}
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
filename "pxelinux.0";
next-server 192.168.134.100;
subnet 192.168.134.0 netmask 255.255.255.0 {
option routers 192.168.134.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.134.200 192.168.134.210;
default-lease-time 21600;
max-lease-time 43200;
}
/etc/xinetd.d/tftp文件中:disable yes改成no
(1)创建kylin和ks目录,用来存放安装源和ks文件
mkdir /var/www/html/kylin
mkdir /var/www/html/ks
mount Kylin-Server-10-SP2-x86-Release-Build09-20210524.iso /mnt/
rsync -a /mnt/ /var/www/html/kylin
chmod -R 755 /var/www/html/
(2)将客户端启动引导所需文件拷贝至/var/lib/tftpboot/目录下
cp -rf /mnt/images/pxeboot/* /var/lib/tftpboot/
cp /mnt/EFI/BOOT/grubx64.efi /mnt/EFI/BOOT/BOOTX64.EFI /var/lib/tftpboot/
chmod 755 /var/lib/tftpboot/*
(1)创建kylin和ks目录,用来存放安装源和ks文件
mkdir /var/www/html/kylin
mkdir /var/www/html/ks
mount Kylin-Server-10-SP2-x86-Release-Build09-20210524.iso /mnt/
rsync -a /mnt/ /var/www/html/kylin
chmod -R 755 /var/www/html/
(2)将客户端启动引导所需文件拷贝至/var/lib/tftpboot/目录下
cp -f /mnt/isolinux/* /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg
cp -f /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
chmod -R 755 /var/lib/tftpboot/*
[root@localhost ~]# vim /var/lib/tftpboot/grub.cfg
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
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install Kylin Linux Advanced Server V10 HTTP' --class red --class gnu-linux --class gnu --class os {
set root=(tftp,192.168.134.100)
linux /vmlinuz ro inst.geoloc=0 console=ttyAMA0 console=tty0 rd.iscsi.waitnet=0 ip=dhcp inst.repo=http://192.168.134.100/kylin inst.ks=http://192.168.134.100/ks/kylin-ks.cfg
initrd /initrd.img
}
[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
default vesamenu.c32
timeout 100
display boot.msg
# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title Kylin Linux Advanced Server V10
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13
# Border Area
menu color border * #00000000 #00000000 none
# Selected item
menu color sel 0 #ffffffff #00000000 none
# Title bar
menu color title 0 #ff7ba3d0 #00000000 none
# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none
# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none
# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none
# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none
# Help text
menu color help 0 #ffffffff #00000000 none
# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none
# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none
# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none
# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.
menu tabmsg Press Tab for full configuration options on menu items.
menu separator # insert an empty line
menu separator # insert an empty line
label http
menu label ^Install Kylin Linux Advanced Server V10 HTTP
menu default
kernel vmlinuz
append initrd=initrd.img ro inst.geoloc=0 console=ttyAMA0 console=tty0 rd.iscsi.waitnet=0 ip=dhcp inst.repo=http://192.168.134.100/kylin inst.ks=http://192.168.134.100/ks/kylin-ks.cfg rd.debug rd.udev.debug systemd.log_level=debug
menu end
[root@localhost ~]# cat /var/www/html/ks/kylin-ks.cfg
# Installation disks
ignoredisk --only-use=sda
autopart --type=lvm
# nfs install
# Partition clearing information
clearpart --drives=sda --all
# Use graphical install
graphical
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Network information
network --bootproto=dhcp --device= --ipv6=auto --activate
network --hostname=localhost.localdomain
# Run the Setup Agent on first boot
firstboot --enable
# X Window System configuration information
xconfig --startxonboot
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --utc --nontp
# Environment groups
# Minimal Install/最小安装
# Server/基础设施服务器
# File and Print Server/文件及打印服务器
# Basic Web Server/基本网页服务器
# Virtualization Host/虚拟化主机
# Server with UKUI GUI/带 UKUI GUI 的服务器
%packages
@^kylin-desktop-environment
wget
%end
# Root password "Kylin123123"
rootpw --iscrypted $6$2RNyJf8iEMumDVFd$jGlgTmmUkLG2NquH9zUfa/S/UJKsBuF5PXdbKdosRYxQOzh4uWaq9tuxL/EwSCmgsjnRNWXu66ILmtSbIBDn.0
# Password policies
%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
%post
# Get kyinfo
wget http://192.168.134.100/kylin/{.kyinfo,LICENSE} --random-wait --directory-prefix /etc/
systemctl unmask systemd-timedated.service
systemctl disable systemd-networkd-wait-online.service
systemctl disable multipathd.service
systemctl enable cockpit.socket
rm -f /1ib/udev/rules.d/60-block-scheduler.rules
rm -f /etc/cron.daily/rpm
sed -i "s/instal1_items/instal1_optional_items/g"/etc/dracut.conf
sed -i "s?/usr/share/fonts/kingsoft/FZKTK.TTF?/usr/share/fonts/goog1e-noto-cjk/NotoSansCJK-Bold.ttc?g"
/etc/dracut.conf
if [! -f "/usr/share/fonts/goog1e-noto-cjk/NotoSansCJK-Bold.ttc"]; then
mkdir -p /usr/share/fonts/google-noto-cjk
wget http://192.168.134.100/ky1in/images/NotoSansCJK-Bold.ttc --random-wait --directory-prefix
/usr/share/fonts/google-noto-cjk/
fi
dracut -f
# Enable kdump
#sed -i "s/ crashkernel=auto / /" /boot/efi/EFI/kylin/grub.cfg
%end
%post
# Get kyinfo
wget http://192.168.134.100/kylin/{.kyinfo,LICENSE} --random-wait --directory-prefix /etc/
systemctl unmask systemd-timedated.service
systemctl disable systemd-networkd-wait-online.service
systemctl disable multipathd.service
systemctl enable cockpit.socket
rm -f /1ib/udev/rules.d/60-block-scheduler.rules
rm -f /etc/cron.daily/rpm
sed -i "s/instal1_items/instal1_optional_items/g"/etc/dracut.conf
sed -i "s?/usr/share/fonts/kingsoft/FZKTK.TTF?/usr/share/fonts/goog1e-noto-cjk/NotoSansCJK-Bold.ttc?g"
/etc/dracut.conf
if [! -f "/usr/share/fonts/goog1e-noto-cjk/NotoSansCJK-Bold.ttc"]; then
mkdir -p /usr/share/fonts/google-noto-cjk
wget http://192.168.134.100/ky1in/images/NotoSansCJK-Bold.ttc --random-wait --directory-prefix
/usr/share/fonts/google-noto-cjk/
fi
dracut -f
systemctl enable httpd && systemctl restart httpd
systemctl enable dhcpd && systemctl restart dhcpd
systemctl enable xinetd && systemctl restart xinetd
systemctl enable tftp && systemctl restart tftp
systemctl disable firewalld && systemctl stop firewalld
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。