feat: add Rocky Linux 10 GRUB-EFI support and RHEL-family improvements#90
Closed
Raboo wants to merge 20 commits intolinka-cloud:mainfrom
Closed
feat: add Rocky Linux 10 GRUB-EFI support and RHEL-family improvements#90Raboo wants to merge 20 commits intolinka-cloud:mainfrom
Raboo wants to merge 20 commits intolinka-cloud:mainfrom
Conversation
Author
|
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
Author
|
@Adphi Hi, when do you think you might have some time over to review my PR? |
Adphi
requested changes
Apr 22, 2026
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.
Author
|
Ok, I have resolved all comments. Please have another look now. |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.