6.2. 创建自定义引导镜像
自定义引导镜像和 GUI 布局后,创建一个新镜像,其中包含您所做的更改。
要创建自定义引导镜像,请按照以下步骤操作。
流程
-
请确定您的所有更改都包含在工作目录中。例如,如果您要测试附加组件,请确保将
product.img
放在images/
目录中。 -
确保您的当前工作目录是提取的 ISO 镜像的顶级目录,例如
/tmp/ISO/iso/
。 安装以下软件包:
isomd5sum
,xorriso
,lorax
:dnf install isomd5sum xorriso lorax
# dnf install isomd5sum xorriso lorax
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 使用
mkefiboot
制作一个 EFI 引导镜像:mkefiboot --label=ANACONDA /tmp/ISO/iso/EFI/BOOT/ /tmp/ISO/iso/images/efiboot.img
# mkefiboot --label=ANACONDA /tmp/ISO/iso/EFI/BOOT/ /tmp/ISO/iso/images/efiboot.img
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 使用
xorrisofs
创建一个新的 ISO 镜像:xorrisofs -o ../NEWISO.iso -R -J -V RHEL-10-0-BaseOS-x86_64 --grub2-mbr /usr/lib/grub/i386-pc/boot_hybrid.img -partition_offset 16 -appended_part_as_gpt -append_partition 2 C12A7328-F81F-11D2-BA4B-00A0C93EC93B /tmp/ISO/iso/images/efiboot.img -iso_mbr_part_type EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 -c boot.cat --boot-catalog-hide -b images/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info -eltorito-alt-boot -e --interval:appended_partition_2:all:: -no-emul-boot -graft-points .discinfo=/tmp/ISO/iso/.discinfo images/install.img=/tmp/ISO/iso/images/install.img images/pxeboot=/tmp/ISO/iso/images/pxeboot boot/grub2=/tmp/ISO/iso/boot/grub2 boot/grub2/i386-pc=/usr/lib/grub/i386-pc images/eltorito.img=/tmp/ISO/iso/images/eltorito.img EFI/BOOT=/tmp/ISO/iso/EFI/BOOT
# xorrisofs -o ../NEWISO.iso -R -J -V RHEL-10-0-BaseOS-x86_64 --grub2-mbr /usr/lib/grub/i386-pc/boot_hybrid.img -partition_offset 16 -appended_part_as_gpt -append_partition 2 C12A7328-F81F-11D2-BA4B-00A0C93EC93B /tmp/ISO/iso/images/efiboot.img -iso_mbr_part_type EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 -c boot.cat --boot-catalog-hide -b images/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info -eltorito-alt-boot -e --interval:appended_partition_2:all:: -no-emul-boot -graft-points .discinfo=/tmp/ISO/iso/.discinfo images/install.img=/tmp/ISO/iso/images/install.img images/pxeboot=/tmp/ISO/iso/images/pxeboot boot/grub2=/tmp/ISO/iso/boot/grub2 boot/grub2/i386-pc=/usr/lib/grub/i386-pc images/eltorito.img=/tmp/ISO/iso/images/eltorito.img EFI/BOOT=/tmp/ISO/iso/EFI/BOOT
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在上例中:
如果您对需要一个位置来在同一磁盘上加载文件的选项使用
LABEL=
指令,请确保-V
选项的值与镜像的引导装载程序配置匹配。如果您的引导装载程序配置(用于 BIOS 的boot/grub2/grub.cfg
和用于 UEFI 的EFI/BOOT/grub.cfg
)使用inst.stage2=LABEL=disk_label
节来从同一磁盘加载安装程序的第二阶段,则磁盘标签必须匹配。重要在引导装载程序配置文件中,将磁盘标签中的所有空格替换为
\x20
。例如,如果您创建了一个带有RHEL 10.0
标签的 ISO 镜像,则引导装载程序配置应使用RHEL\x2010.0
。-
将
-o
选项(-o ../NEWISO.iso
)的值替换为新镜像的文件名。示例中的值在当前目录 上面的 目录中创建NEWISO.iso
文件。有关这个命令的详情请参考您系统上的xorrisofs (1)
手册页。
在镜像中省略 MD5 checksum。请注意,如果没有 MD5 检验和,镜像验证检查可能会失败(引导装载程序配置中的
rd.live.check
选项),安装可能会挂起。implantisomd5 ../NEWISO.iso
# implantisomd5 ../NEWISO.iso
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在上例中, 使用文件名和您在上一步中创建的 ISO 镜像位置替换 ../NEWISO.iso。
现在,您可以将新 ISO 镜像写入到物理介质或网络服务器,来在物理硬件上启动它,或者您可以使用它来开始安装虚拟机。