m/installer/install: embed bios_bootcode
We have a BIOS bootcode which displays a message that only UEFI boot is
supported, but this was not installed anywhere. Now it's included in the
installer and in installed nodes.
Change-Id: I319fcd30ad3eacbfdcb9bf7d95925e51ff896570
Reviewed-on: https://review.monogon.dev/c/monogon/+/4378
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/cli/metroctl/core/install.go b/metropolis/cli/metroctl/core/install.go
index 31fe4a0..5a41fc7 100644
--- a/metropolis/cli/metroctl/core/install.go
+++ b/metropolis/cli/metroctl/core/install.go
@@ -47,7 +47,8 @@
if err != nil {
return fmt.Errorf("failed to read OS image: %w", err)
}
- bootPath, err := install.EFIBootPath(osImage.Config.ProductInfo.Architecture())
+ architecture := osImage.Config.ProductInfo.Architecture()
+ bootPath, err := install.EFIBootPath(architecture)
if err != nil {
return err
}
@@ -88,6 +89,9 @@
if err != nil {
return fmt.Errorf("target device has invalid geometry: %w", err)
}
+ if architecture == "x86_64" {
+ partTable.BootCode = install.BootcodeX86
+ }
esp := gpt.Partition{
Type: gpt.PartitionTypeEFISystem,
Name: "MetropolisInstaller",
diff --git a/metropolis/installer/install/BUILD.bazel b/metropolis/installer/install/BUILD.bazel
index 1a0fed3..2cd2fdc 100644
--- a/metropolis/installer/install/BUILD.bazel
+++ b/metropolis/installer/install/BUILD.bazel
@@ -3,6 +3,9 @@
go_library(
name = "install",
srcs = ["install.go"],
+ embedsrcs = [
+ "//metropolis/node/bios_bootcode", #keep
+ ],
importpath = "source.monogon.dev/metropolis/installer/install",
visibility = ["//visibility:public"],
deps = [
diff --git a/metropolis/installer/install/install.go b/metropolis/installer/install/install.go
index dda3b7a..4d93723 100644
--- a/metropolis/installer/install/install.go
+++ b/metropolis/installer/install/install.go
@@ -6,6 +6,7 @@
package install
import (
+ _ "embed"
"fmt"
"io"
@@ -53,6 +54,9 @@
return "EFI/BOOT/" + bootName, nil
}
+//go:embed metropolis/node/bios_bootcode/boot.bin
+var BootcodeX86 []byte
+
// PartitionSizeInfo contains parameters used during partition table
// initialization and, in case of image files, space allocation.
type PartitionSizeInfo struct {
@@ -93,9 +97,6 @@
// PartitionSize specifies a size for the ESP, Metropolis System and
// Metropolis data partition.
PartitionSize PartitionSizeInfo
- // BIOSBootCode provides the optional contents for the protective MBR
- // block which gets executed by legacy BIOS boot.
- BIOSBootCode []byte
}
type plan struct {
@@ -179,7 +180,10 @@
}
params.tbl.ID = params.DiskGUID
- params.tbl.BootCode = p.BIOSBootCode
+ architecture := p.OSImage.Config.ProductInfo.Architecture()
+ if architecture == "x86_64" {
+ params.tbl.BootCode = BootcodeX86
+ }
params.efiPartition = &gpt.Partition{
Type: gpt.PartitionTypeEFISystem,
Name: ESPLabel,
@@ -193,7 +197,7 @@
return nil, err
}
// Place the A/B loader at the EFI bootloader autodiscovery path.
- params.efiBootPath, err = EFIBootPath(p.OSImage.Config.ProductInfo.Architecture())
+ params.efiBootPath, err = EFIBootPath(architecture)
if err != nil {
return nil, err
}