最近遇到了一个不算大的问题,就是信创的国产化操作系统安装,机器可能会有个几十台,没台去装肯定累个够呛……
开始正题吧,完成任务需要几个工具nginx、tftp-hpa、isc-dhcp-server、系统镜像。
首先安装一个nginx作为http下载文件的用途(这个最简单基本不用配置啥)
apt install nginx
还需要一个镜像,当然是麒麟镜像。去官网瞅了下,就这还得注册才给测试链接……忍着恶心注册了一把,拿到链接一看版本还挺丰富。于是下载了一个x86_64版本的镜像。
因为要用pxe安装所以需要引导文件,于是抽取文件到tftp文件下默认路径是srv/tftp,新建目录grub/下需要两个文件grubx64.efi和grub.cfg,grub.cfg如下内容
set default="0"function load_video {insmod efi_gopinsmod efi_ugainsmod video_bochsinsmod video_cirrusinsmod all_video}load_videoset gfxpayload=keepinsmod gzioinsmod part_gptinsmod ext2set timeout=3search --no-floppy --set=root -l 'Kylin-Server-10'menuentry '1)Install Kylin Desktop V10.1 1106 X86' --class red --class gnu-linux --class gnu --class os {linux install/vmlinuz inst.stage2=http://192.168.1.14 quit inst.ks=http://192.168.1.14/ks.cfginitrd install/initrd.img}
对应kickstart文件如下:
# Install OS instead of upgradeinstall# Keyboard layouts# old format: keyboard us# new format:keyboard --vckeymap=cn --xlayouts='cn'# Root passwordrootpw --iscrypted $1$p9c/UtoB$F/NKPL3Rc92T/MIFuuwXP1# Use network installationurl --url="http://192.168.1.14"# System languagelang zh_CNuser --name=app --password=$6$HYxUdlffGmKv.D3V$fwl9CSR30j8qN4GURB3CJl7h1OTpwGtKP3LHadU0U4MUDGFCwFBCcef.UqxXWqSKx7adk2nDHZbQIX6lvMOFf0 --iscrypted --gecos="app"# System authorization informationauth --useshadow --passalgo=sha512# Use graphical installtext# Run the Setup Agent on first bootfirstboot --enable# SELinux configurationselinux --disabled# System servicesservices --enabled="chronyd"ignoredisk --only-use=sda# Firewall configurationfirewall --disabled# Network informationnetwork --bootproto=dhcp --device=enp11s0f1 --onboot=onrebooteula --agreed# System timezonetimezone Asia/Shanghai#network --bootproto=dhcp --device=enp11s0f0 --onboot=on# System bootloader configurationbootloader --append="crashkernel=auto" --location=mbr --boot-drive=sda# Clear the Master Boot Recordzerombr# Partition clearing informationclearpart --all --initlabel --drives=sda# Disk partitioning informationpart boot --fstype="xfs" --size=1024part boot/efi --fstype="vfat" --size=512part swap --fstype="swap" --size=4096part --fstype="xfs" --grow --size=1%packageschronykexec-tools%end
还需要在/srv/tftp下创建install目录,里面存放initrd.img和vmlinuz两个文件
下面就是使用mount 挂在镜像光盘mount -o loop Kylin-Server-10-SP2-X86-Release-Build09-20210524.iso /mnt
cp -ar * /var/www/html目录下,最后一步就是配置dhcp了
subnet 192.168.1.0 netmask 255.255.255.0 {range 192.168.1.100 192.168.1.200;option broadcast-address 192.168.1.255;option routers 192.168.1.14;next-server 192.168.1.14;filename "grup/grubx64.efi";#uefi引导使用这个文件,legacy引导使用pxelinux.0option subnet-mask 255.255.255.0;}
配置完成后就可以顺利的进行网络安装了。
文章转载自DevOps踩坑与实践,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




