银河麒麟V10 SP3 2403 PXE安装

银河麒麟V10 SP3 2403 PXE安装

一、系统准备

安装好麒麟操作系统,关闭防火墙,关闭selinux,配置本地源,将镜像放置在/root目录下

systemctl disable firewalld --now
#selinux默认是关闭的

关闭默认源,追加本地源

#设置enabled = 0
sed -i -E 's/(enabled\s*=\s*)1/\10/g' /etc/yum.repos.d/kylin_x86_64.repo

tee -a /etc/yum.repos.d/kylin_x86_64.repo > /dev/null <<EOF
[ks10-ISO]
name = Kylin local
baseurl = file:///mnt/iso
gpgcheck = 0
enable = 1
EOF

mkdir /mnt/iso
mount /root/Kylin-Server-V10-SP3-2403-Release-20240426-x86_64.iso /mnt/iso

yum repolist

二、安装软件包

安装httpd dnsmasq和syslinux-nonlinux

yum install httpd dnsmasq syslinux-nonlinux -y

三、配置服务

3.1 配置dnsmasq

mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
tee /etc/dnsmasq.conf > /dev/null << EOF
interface=ens33
#dnsmasq使用的网卡

log-dhcp
log-facility=/var/log/dnsmasq.log
#记录DHCP日志

dhcp-range=192.168.74.200,192.168.74.250,255.255.255.0,12h
#dhcp地址池及租期

dhcp-option=option:router,192.168.74.2
#dhcp网关(直连交换机其实可以不配置网关)

dhcp-option=66,192.168.74.133
#TFTPserver地址(修改为本机的地址)

dhcp-match=set:efi-x86_64,option:client-arch,7  # EFI BC (某些x86-64)
dhcp-match=set:efi-x86_64,option:client-arch,9  # EFI x86-64
dhcp-match=set:efi-x86,option:client-arch,6     # EFI IA32 (x86-32)
dhcp-match=set:bios,option:client-arch,0        # 传统BIOS
dhcp-match=set:efi-arm64,option:client-arch,11  # ARM 64位UEFI
dhcp-match=set:efi-arm32,option:client-arch,10  # ARM 32位UEFI
#使用架构标签

#dhcp-userclass=set:iPXEBoot,iPXE
#自定义标签set tag "iPXEBoot" if request comes from iPXE ("iPXE" user class)

dhcp-boot=tag:efi-x86_64,grubx64.efi
dhcp-boot=tag:bios,pxelinux.0
dhcp-boot=tag:efi-arm64,grubaa64.efi
#按架构标签返回启动文件

#dhcp-boot=tag:iPXEBoot,http://192.168.199.20/esxi/ipxe.script
#当iPXE启动后,使iPXE启动http服务器上的脚本

enable-tftp
#开启TFTP

tftp-root=/var/tftpboot
#TFTP根目录
conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig
EOF

3.2 配置httpd服务

#创建kylin和ks⽬录,⽤来存放安装源和ks⽂件
#mkdir /var/www/html/kylin
ln -s /mnt/iso /var/www/html/kylin
mkdir /var/www/html/ks
chmod -R 755 /var/www/html/
#将UEFI客⼾端启动引导所需⽂件拷⻉⾄/var/tftpboot/⽬录下
mkdir /var/tftpboot
cp -rf /mnt/iso/images/pxeboot/* /var/tftpboot/
cp /mnt/iso/EFI/BOOT/grubx64.efi /mnt/iso/EFI/BOOT/BOOTX64.EFI /var/tftpboot/

#legacy将客⼾端启动引导所需⽂件拷⻉⾄/var/tftpboot/⽬录下
cp -rf /mnt/iso/isolinux/* /var/tftpboot/
mkdir /var/tftpboot/pxelinux.cfg
cp -f /usr/share/syslinux/pxelinux.0 /var/tftpboot/
chmod -R 755 /var/tftpboot/*

3.3 配置启动菜单

3.3.1 UEFI的grub.cfg文件配置

tee /var/tftpboot/grub.cfg > /dev/null << 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=2

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install Kylin Linux Advanced Server V10 HTTP' --class red --class gnulinux --class gnu --class os {
    set root=(tftp,192.168.74.133)
    linux /vmlinuz ro inst.geoloc=0 console=ttyAMA0 console=tty0 rd.iscsi.waitnet=0 ip=dhcp inst.repo=http://192.168.74.133/kylin inst.ks=http://192.168.74.133/ks/kylin-ks.cfg
    initrd /initrd.img
}
EOF

3.3.2 Legacy的default文件配置

tee /var/tftpboot/pxelinux.cfg/default > /dev/null << EOF
default vesamenu.c32
timeout 20
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.74.133/kylin inst.ks=http://192.168.74.133/ks/kylin-ks.cfg rd.debug rd.udev.debug systemd.log_level=debug
menu end
EOF

3.3.3 ks应答文件配置

tee /var/www/html/ks/kylin-ks.cfg > /dev/null << EOF
#version=DEVEL
eula --agreed
# Use graphical install
graphical

%post --nochroot
%end

%post
# Get kyinfo
wget http://192.168.74.133/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.74.133/ky1in/images/NotoSansCJK-Bold.ttc --random-wait --directory-prefix /usr/share/fonts/google-noto-cjk/
fi
dracut -f

#以上post内容为麒麟文档中说明必须添加的部分!!!
eula --agreed
systemctl disable initial-setup.service
curl -o /root/Kylin-Server-V10-SP3-2403-Release-20240426-x86_64.iso http://192.168.74.133/ks/Kylin-Server-V10-SP3-2403-Release-20240426-x86_64.iso
%end

%packages
@^minimal-environment
wget
bash-completion
vim

%end

# Keyboard layouts
keyboard --xlayouts='cn'
# System language
lang zh_CN.UTF-8

# Network information
#network  --bootproto=dhcp --device=ens33 --onboot=on --ipv6=auto --no-activate
#network  --bootproto=dhcp --device=ens34 --onboot=off --ipv6=auto
#network  --bootproto=dhcp --device=ens35 --onboot=off --ipv6=auto
#network  --bootproto=dhcp --device=bond0 --ipv6=auto --no-activate --bondslaves=ens34,ens35 --bondopts=mode=802.3ad,downdelay=0,miimon=1,updelay=0
#network  --hostname=localhost.localdomain

# Use CDROM installation media
#cdrom

# Run the Setup Agent on first boot
firstboot --enable
# System services
services --disabled="chronyd"

# Installation disks
ignoredisk --only-use=sda
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --ondisk=sda --size=1024
part /boot/efi --fstype="efi" --size=600 --fsoptions="umask=0077,shortname=winnt"
part pv.111 --fstype="lvmpv" --ondisk=sda --size=1 --grow
volgroup klas --pesize=4096 pv.111
logvol / --fstype="xfs" --size=1 --grow --name=root --vgname=klas
logvol swap --fstype="swap" --size=1024 --name=swap --vgname=klas

timesource --ntp-disable
# System timezone
timezone Asia/Shanghai --utc

# Root password
# Root password "Kylin123123"
rootpw --iscrypted $6$2RNyJf8iEMumDVFd$jGlgTmmUkLG2NquH9zUfa/S/UJKsBuF5PXdbKdosRYxQOzh4uWaq9tuxL/EwSCmgsjnRNWXu66ILmtSbIBDn.0

%addon com_redhat_kdump --disable --reserve-mb='128'

%end

%anaconda
pwpolicy root --minlen=8 --minquality=1 --strict --nochanges --notempty
pwpolicy user --minlen=8 --minquality=1 --strict --nochanges --emptyok
pwpolicy luks --minlen=8 --minquality=1 --strict --nochanges --notempty
%end
reboot
EOF

四、启动服务

systemctl start httpd dnsmasq 

五、客户端测试

posted @ 2025-04-15 10:34  Holdmyhand  阅读(928)  评论(0)    收藏  举报