feat: add Rocky Linux 10 GRUB-EFI support and RHEL-family improvements#90
feat: add Rocky Linux 10 GRUB-EFI support and RHEL-family improvements#90Raboo wants to merge 20 commits into
Conversation
|
I have a working image that boots Rocky 10.1 using uefi, I haven't tested secure boot, but it ought to work. |
…dling - Add isRhelFamily() helper to centralize RHEL-family distro detection - Use grub2-install/grub2-mkconfig for all RHEL-family distros (CentOS, Rocky, AlmaLinux, RHEL) - Enable grub and grub-efi bootloaders for Rocky, AlmaLinux, and CentOS - Copy distro-specific EFI binary to removable boot path for RHEL-family EFI support - Consolidate SupportsLUKS() switch cases for RHEL-family distros
grub2-install on RHEL-family EFI platforms requires --force when running in a chroot/offline environment without EFI variables. This is standard for VM image building scenarios.
- Add templates/rocky.Dockerfile for Rocky/AlmaLinux image builds - Add examples/rocky.Dockerfile following existing example patterns - Route Rocky and AlmaLinux to use the new rocky template - Keep CentOS using its own centos.Dockerfile template
network-scripts were removed in RHEL 9+. Rocky Linux 10 uses NetworkManager exclusively, which handles DHCP on eth0 by default.
The --removable flag passed to grub2-install already places the EFI binary at the standard removable boot path. The copyEfiBinary function was redundant and always logged a warning about not finding the source file. Remove it along with unused imports.
- Add filesystem labels (rootfs, boot) to mkfs commands in builder - Add RHEL-specific grub config template with GRUB_ENABLE_BLSCFG=false and GRUB_DISABLE_LINUX_UUID=true to prevent duplicate root/ro/initrd - Write /etc/fstab with LABEL-based entries so grub2-mkconfig correctly detects separate /boot partition and generates relative paths - Set root=LABEL=rootfs in GRUB_CMDLINE_LINUX for portable root device
…kconfig grub2-mkconfig in a chroot environment leaks the host's /proc/cmdline (loop device paths) and produces duplicate root=, ro, and initrd= entries. Replace it with a custom grub.cfg generator for RHEL-family that: - Uses label-based boot partition lookup (search --label boot) - Uses label-based root device (root=LABEL=rootfs) - Generates correct relative paths for kernel/initrd (no /boot prefix) - Produces a single clean menuentry with no duplicates Also add SplitBoot and BootFS fields to Config struct so grubCommon can access them for template generation.
Since we now generate grub.cfg directly for RHEL-family instead of using grub2-mkconfig, the RHEL-specific /etc/default/grub template is no longer needed. Simplify prepare() to use the standard template for all distros.
- Set timeout=5 so users can interrupt boot to edit grub entries - Remove load_video which fails with 'can't find command' error in minimal grub environment and is unnecessary for serial console VMs
Create /.autorelabel during image build so the first boot triggers a full filesystem relabel. This is required because SELinux contexts from the Docker build don't match the policy loaded at boot time.
0c9be91 to
f27c011
Compare
|
@Adphi Hi, when do you think you might have some time over to review my PR? |
These fields were assigned but never read. The builder struct has its own splitBoot and bootFS fields that are used throughout the codebase.
…elease.go This change was out of scope for this PR.
Remove the skip for centos/almalinux/rocky EFI tests now that grub2-install with --force works in chroot environments.
Remove the dedicated rocky.Dockerfile template and instead use the centOS template for Rocky Linux and AlmaLinux releases. This reduces template duplication as the base package installations and configurations are now unified across these RHEL-family distributions.
Instead of adding a field to Config, Cmdline now takes OSRelease and calls isRhelFamily() to choose the correct kernel cmdline format. RHEL-family distros omit 'ro initrd=...' prefix; others keep it.
Include Docker Inc's official images and Rocky Linux Project official images for versions 9 and 10.
- Remove custom mkconfigRhel, fall back to grub2-mkconfig - Set GRUB_TIMEOUT=1 to allow editing boot entries - Remove root=LABEL=rootfs from GRUB_CMDLINE_LINUX (passed via cmdline)
For split-boot setups, strip /boot/ prefix from paths in /boot/loader/entries/ files since the boot partition is mounted at / at runtime.
|
Ok, I have resolved all comments. Please have another look now. |
|
@Adphi Ok fair enough. But your PR doesn't fix some of the "quality" issues. I tried latest master and it still produces duplicate initrd settings (even if the initrd on the kernel line is ignored, it shouldn't be there, it's also referring to a file that doesn't exist), duplicate "ro", duplicate "root" disk entries. It works, image is bootable, but I feel that quality could be better. Regarding the grub defaults, I assume that disabling the OS prober fixed the wrong path issue (/boot/). And disabling BLSCFG, solves the I also have opinions about making grub menu hidden and with no timeout. Makes it hard to fix any boot issues that might occur or booting into recovery mode. Same here, RHEL default (pretty sure ubuntu as well) is to show it and have a timeout. If it were my choice, I would opt to keep as much as the OS default behaviors as much as possible. Do you have plans to address these stuff? Do you want me to submit smaller PR's to fix these issues? Or do we let it stay as it is? |
|
@Raboo I don't plan to address those. For d2vm-generated images, we don't really care about preserving RHEL defaults for boot-related behavior. These images are intended to be minimal immutable artifacts, not general-purpose installed systems that users maintain through GRUB, recover through the GRUB menu, or expect to behave exactly like a normal RHEL installation. The priority here is that the generated VM boots reliably and as fast as possible. So keeping the GRUB menu visible, preserving
So disabling OS prober is a build isolation measure. It prevents unrelated host/build-environment OS entries from being discovered. It does not rewrite kernel or initrd paths. The relevant change in #91 is Your PR tried to address that by rewriting Regarding the duplicate So I would rather keep the current behavior unless there is a concrete boot failure caused by it. |
Summary
grub2-installfor RHEL-family distros: ExtendednewGrubCommon()to usegrub2commands for all RHEL-family distros: CentOS, Rocky, AlmaLinux, and RHEL. Previously only CentOS was handled.grubandgrub-efibootloaders for RHEL-family: Removed the blocks that prevented Rocky, AlmaLinux, and CentOS from using these bootloaders.--forceflag for EFI install: Required forgrub2-installon RHEL-family EFI platforms when running in a chroot/offline environment without EFI variables.GRUB_TIMEOUT=1to allow editing boot entries, clearedGRUB_CMDLINE_LINUX(root passed via cmdline args).rootfs, boot partition labeledboot(or namebootfor FAT32) for portable GRUBsearchcommands./.autorelabelduring image build so the first boot triggers a full filesystem relabel, required because SELinux contexts from Docker builds don't match the policy loaded at boot time.Config.Cmdline()now usesisRhelFamily()to choose the correct format — RHEL-family distros omit thero initrd=...prefix.fixLoaderEntries()strips/boot/prefix from paths in/boot/loader/entries/files for split-boot setups.examples/rocky.Dockerfilefor Rocky Linux 10.Testing
Successfully converted a Rocky Linux 10.1 Docker image to qcow2 with
--bootloader=grub-efi --split-boot --boot-fs=fat32:Output: A qcow2 image, boots successfully.
Files Changed
grub_common.goisRhelFamily()helper, extendgrub2support, add SELinux autorelabel, adjust grubCfggrub.go--forceflag for EFI install, remove RHEL-family blockgrub_efi.go--forceflag for EFI install, remove RHEL-family blockbuilder.goOSReleasetoCmdline(), addfixLoaderEntries()config.goOSReleasetoCmdline()for RHEL-family kernel cmdline formate2e/e2e_test.goexamples/rocky.DockerfileThis PR was coded with OpenCode using model Qwen3.6-35-A3B.