From a50511de74db08a0b4426be88bb52ce860a008a4 Mon Sep 17 00:00:00 2001 From: builder Date: Fri, 22 May 2026 16:10:42 -0400 Subject: [PATCH] grub: EFI-at-/boot fallback for BOOT-less SBC layout in Upgrade path --- .../v1alpha1/bootloader/grub/upgrade.go | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/internal/app/machined/pkg/runtime/v1alpha1/bootloader/grub/upgrade.go b/internal/app/machined/pkg/runtime/v1alpha1/bootloader/grub/upgrade.go index 9e3f86b84..e99bf2939 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/bootloader/grub/upgrade.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/bootloader/grub/upgrade.go @@ -6,6 +6,7 @@ package grub import ( "context" + "fmt" "path/filepath" "github.com/siderolabs/go-blockdevice/v2/blkid" @@ -18,12 +19,12 @@ import ( // Upgrade copies new boot assets and updates grub configuration on an existing installation. func (c *Config) Upgrade(opts options.InstallOptions) (*options.InstallResult, error) { - mountSpecs := []mount.Spec{ - { - PartitionLabel: constants.BootPartitionLabel, - FilesystemType: partition.FilesystemTypeXFS, - MountTarget: filepath.Join(opts.MountPrefix, constants.BootMountPoint), - }, + var mountSpecs []mount.Spec + + bootMountSpec := mount.Spec{ + PartitionLabel: constants.BootPartitionLabel, + FilesystemType: partition.FilesystemTypeXFS, + MountTarget: filepath.Join(opts.MountPrefix, constants.BootMountPoint), } efiMountSpec := mount.Spec{ @@ -32,6 +33,23 @@ func (c *Config) Upgrade(opts options.InstallOptions) (*options.InstallResult, e MountTarget: filepath.Join(opts.MountPrefix, constants.EFIMountPoint), } + // check if the BOOT partition is present (absent on SBC layouts like RPi5/CM5) + if err := mount.PartitionOp( + opts.BootDisk, + []mount.Spec{bootMountSpec}, + func() error { + return nil + }, + []blkid.ProbeOption{ + blkid.WithSkipLocking(true), + }, + nil, + nil, + opts.BlkidInfo, + ); err == nil { + mountSpecs = append(mountSpecs, bootMountSpec) + } + var efiFound bool // check if the EFI partition is present @@ -49,12 +67,21 @@ func (c *Config) Upgrade(opts options.InstallOptions) (*options.InstallResult, e opts.BlkidInfo, ); err == nil { efiFound = true - } - if efiFound { + if len(mountSpecs) == 0 { + // No BOOT partition (SBC layout): mount EFI at /boot so GRUB + // can find kernel/initramfs/grub.cfg in the expected place. + efiMountSpec.MountTarget = filepath.Join(opts.MountPrefix, constants.BootMountPoint) + c.bootFromEFI = true + } + mountSpecs = append(mountSpecs, efiMountSpec) } + if len(mountSpecs) == 0 { + return nil, fmt.Errorf("neither BOOT nor EFI partition found on disk %s", opts.BootDisk) + } + err := mount.PartitionOp( opts.BootDisk, mountSpecs, -- 2.50.1 (Apple Git-155)