国产麒麟系统PXE安装-传统bios(legacy)引导

自动化脚本扣我

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}
# 注意一定是"/kylin_iso/",两边的斜杠都要有
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文件在光盘里,包名叫:syslinux-nonlinux-6.04-5.ky10.noarch.rpm
filename "pxelinux.0";
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
systemctl start dhcpd
systemctl enable dhcpd


4.配置tftp,获取引导文件

yum -y install tftp tftp-server xinetd
\cp -f /kylin_iso/isolinux/* /var/lib/tftpboot/
\cp -f /kylin_iso/images/pxeboot/* /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg

cat >/var/lib/tftpboot/pxelinux.cfg/default<<EOF
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://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
menu end
EOF

\cp -f /kylin_iso/Packages/syslinux-nonlinux-* /tmp
rm -rf /tmp/usr
cd /tmp
rpm2cpio /tmp/syslinux-nonlinux-* | cpio -idm --quiet
\cp -f /tmp/usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
chmod -R 755 /var/lib/tftpboot/


5.配置kickstart文件

cat >/var/www/html/ks/kylin-ks.cfg<<EOF
#Installation disks
ignoredisk --only-use=sda
autopart --type=lvm

#Partition clearing information
clearpart --drives=sda --all --initlabel
#Use graphical install
graphical

#Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'

#System language
lang zh_CN.UTF-8
#Network infotmation
network --bootproto=dhcp --device=ens33 --ipv6=auto --activate
#network  --bootproto=static --device=ens33 --gateway=172.28.28.254 --ip=172.28.28.20 --nameserver=114.114.114.114,8.8.8.8 --netmask=255.255.255.0 --ipv6=auto --activate
network --hostname=pxe-test1

#Run the setup agent on first boot
firstboot --disable

#X windows system configutation information
xconfig --startxonboot
skipx

#eula --agreed
#System services
services --enabled="chronyd"

#System timezone
timezone Asia/Shanghai --isUtc
#Environment groups
#Minimal Install/最小安装
#Server/基础设施服务器
#File and Print Server/文件及打印服务器
#Basic Web Server/基本网页服务器
#Virtualization Host/虚拟化主机
#Server with UKUI GUI/带 UKUI GUI 的服务器
%packages
@^Minimal Install
wget
bash-completion
%end

#Root password
rootpw --iscrypted $6$ERDzLOaKy1c0fk3P$IzOQAciOaQM59IEeJ9XlXJjGn71C1on2msh5m2zgmjPNNAf6Ukju8u5RlNeQNpgbmsxBBoCE5V.N7WtNS/X2R/

#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
reboot
eula --agreed
%post
#Get kyinfo
wget http://172.28.28.20/kylin/{.kyinfo,LICENSE} --random-wait --directory-prefix /etc/
#Enable kdump
sed -i "s/ crashkernel=auto / /" /boot/efi/EFI/BOOT/kylin/grub.cfg
%end
EOF



6.启动各服务

chmod -R 755 /var/www/html
chmod -R 755 /var/lib/tftpboot
systemctl restart httpd dhcpd tftp xinetd
sytemctl enable httpd dhcpd tftp xinetd


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

河 静

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值