通过 ks.cfg 文件实现 openEuler 系统自动部署

一、环境准备

部署好系统,并准备好工具和文件

bash 复制代码
# 安装软件,创建目录
dnf install xorriso vim -y
mkdir -p /opt/openEuler/

# 将镜像文件 openEuler-24.03-LTS-x86_64-dvd.iso 上传到 /opt 目录下,并解压到指定目录
# 直接用挂载 iso 文件的方式没有试过,效果应该是一样的
xorriso -osirrox on -indev /opt/openEuler-24.03-LTS-x86_64-dvd.iso -extract / /opt/openEuler/

# 复制并编辑 ks.cfg
cp anaconda-ks.cfg /opt/openEuler/isolinux/ks.cfg

二、编辑 ks.cfg 文件

以下是参考文件,各配置项的详细解释可参考官方文档:Red Hat Enterprise Linux | 7 | Red Hat Documentation

bash 复制代码
# Generated by Anaconda 36.16.5
# Generated by pykickstart v3.48
#version=DEVEL
# Use graphical install
graphical

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

# Use CDROM  installation media
cdrom

network --hostname=server

%packages
@^minimal-environment
@standard
%end

# Run the Setup Agent on first boot
firstboot --disable

skipx
services --disable="chronyd"

# Generated using Blivet version 3.8.2
ignoredisk --only-use=sda
autopart --type=lvm
# Partition clearing information
clearpart --none --initlabel

# System timezone
timezone Asia/Shanghai --utc

# Reboot after installation
reboot

# Root password
rootpw --iscrypted $6$o.1XeHSD7HsYuSpA$TtA5I3m4fI2zcDjT.tvBMtLSLJh1soihICDKJFoi82

%post

sed -i "s/ ro / ro crashkernel=1024M,high /" /boot/efi/EFI/openEuler/grub.cfg

%end

三、修改启动引导文件

  1. BIOS 启动文件,只展示需要修改的部分
bash 复制代码
# chmod +w/opt/openEuler/isolinux/isolinux.cfg
#vim /opt/openEuler/isolinux/isolinux.cfg

label linux
  menu label ^Install openEuler 24.03-LTS
  menu default
  kernel vmlinuz
  append initrd=initrd.img inst.ks=cdrom:/isolinux/ks.cfg

label check
  menu label Test this ^media & install openEuler 24.03-LTS
#  menu default
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=openEuler-24.03-LTS-x86_64 rd.live.check quiet fpi_to_tail=off

menu separator # insert an empty line
  1. EFI 启动文件,只展示需要修改的部分
bash 复制代码
# chmod +w /opt/openEuler/EFI/BOOT/grub.cfg
# vim /opt/openEuler/EFI/BOOT/grub.cfg

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Install openEuler 24.03-LTS' --class openEuler --class gnu-linux --class gnu --class os {
        linuxefi /images/pxeboot/vmlinuz inst.ks=cdrom:/isolinux/ks.cfg
        initrdefi /images/pxeboot/initrd.img
}
menuentry 'Test this media & install openEuler 24.03-LTS' --class openEuler --class gnu-linux --class gnu --class os {
        linuxefi /images/pxeboot/vmlinuz inst.stage2=hd:LABEL=openEuler-24.03-LTS-x86_64 rd.live.check fpi_to_tail=off
        initrdefi /images/pxeboot/initrd.img
}

四、生成镜像文件

bash 复制代码
cd /opt/openEuler/

# 以下命令中一些参数不是必须的,具体可自行测试
xorriso -as mkisofs -o /opt/openEuler.iso \
-V 'openEuler' \
-partition_cyl_align off \
-partition_offset 0 \
--mbr-force-bootable \
--gpt-iso-not-ro \
-iso_mbr_part_type 0x00 \
-c '/isolinux/boot.cat' \
-b '/isolinux/isolinux.bin' \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
-eltorito-alt-boot \
-e '/images/efiboot.img' \
-no-emul-boot \
-boot-load-size 14064 \
-isohybrid-gpt-basdat \
-R -J -v -T ./
相关推荐
Lovyk1 分钟前
Linux Shell 常用操作与脚本示例详解
linux·运维·服务器
iCan_qi37 分钟前
【Mac】【Minecraft】关于如何在Mac上搭建基岩版MC服务器的方法
运维·服务器·macos·minecraft
ezreal_pan3 小时前
Kubernetes 负载均衡现象解析:为何同一批次请求集中于单个 Pod
运维·云原生·k8s·traefik
朱皮皮呀3 小时前
Spring Cloud——服务注册与服务发现原理与实现
运维·spring cloud·eureka·服务发现·php
云边云科技4 小时前
零售行业新店网络零接触部署场景下,如何选择SDWAN
运维·服务器·网络·人工智能·安全·边缘计算·零售
城管不管5 小时前
Docker核心---数据卷(堵门秘籍)
运维·docker·容器
AOwhisky5 小时前
Linux 文本处理三剑客:awk、grep、sed 完全指南
linux·运维·服务器·网络·云计算·运维开发
xuanerya5 小时前
使用 SSH 方式克隆 GitHub 仓库没有权限解决办法
运维·ssh·github
runfarther6 小时前
搭建LLaMA-Factory环境
linux·运维·服务器·python·自然语言处理·ai编程·llama-factory
百思可瑞教育6 小时前
Spring Cloud Gateway 负载均衡全面指南
运维·负载均衡·北京百思可瑞教育·百思可瑞教育·北京百思教育