talos-rpi5/patches/siderolabs/talos/0006-grub-EFI-at-boot-fallback-for-BOOT-less-SBC-layout-i.patch
Mathias Beaulieu-Duncan 8fada1ebfe patches: restore 0006 grub EFI-at-/boot fallback for BOOT-less SBC Upgrade
This patch file mirrors a commit that already existed in checkouts/talos
(`a50511de7` — "grub: EFI-at-/boot fallback for BOOT-less SBC layout in
Upgrade path") but was never landed back into patches/siderolabs/talos/.
Extracted with `git format-patch` from the checkout so subsequent
`make patches` runs reproduce the same tree on a fresh clone.

Complements 0005 by handling the Upgrade code-path (in addition to the
fresh-install code-path 0005 already covers) for SBC layouts that don't
have a separate BOOT partition.
2026-05-25 20:04:17 -04:00

93 lines
2.8 KiB
Diff

From a50511de74db08a0b4426be88bb52ce860a008a4 Mon Sep 17 00:00:00 2001
From: builder <build@svrnty.io>
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)