metropolis/node/core/update: set partition start and size in efi

Change-Id: I1dc6b6738a375c6fc581d51494d13fbeda7b724d
Reviewed-on: https://review.monogon.dev/c/monogon/+/2026
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/node/core/localstorage/crypt/blockdev.go b/metropolis/node/core/localstorage/crypt/blockdev.go
index 532033e..9f04660 100644
--- a/metropolis/node/core/localstorage/crypt/blockdev.go
+++ b/metropolis/node/core/localstorage/crypt/blockdev.go
@@ -164,7 +164,7 @@
 
 	part := table.Partitions[pi.partNumber-1]
 
-	updateSvc.ProvideESP("/esp", part.ID, uint32(pi.partNumber))
+	updateSvc.ProvideESP("/esp", uint32(pi.partNumber), part)
 
 	nodePath := nodePathForPartitionType(part.Type)
 	if nodePath == "" {
diff --git a/metropolis/node/core/update/BUILD.bazel b/metropolis/node/core/update/BUILD.bazel
index 4bb7915..143231b 100644
--- a/metropolis/node/core/update/BUILD.bazel
+++ b/metropolis/node/core/update/BUILD.bazel
@@ -9,9 +9,9 @@
         "//metropolis/node/build/mkimage/osimage",
         "//metropolis/pkg/blockdev",
         "//metropolis/pkg/efivarfs",
+        "//metropolis/pkg/gpt",
         "//metropolis/pkg/logtree",
         "@com_github_cenkalti_backoff_v4//:backoff",
-        "@com_github_google_uuid//:uuid",
         "@org_golang_google_grpc//codes",
         "@org_golang_google_grpc//status",
     ],
diff --git a/metropolis/node/core/update/e2e/testos/main.go b/metropolis/node/core/update/e2e/testos/main.go
index b780d17..cae004c 100644
--- a/metropolis/node/core/update/e2e/testos/main.go
+++ b/metropolis/node/core/update/e2e/testos/main.go
@@ -109,7 +109,7 @@
 			if err := unix.Mount(fmt.Sprintf("/dev/vda%d", pn+1), "/esp", "vfat", unix.MS_SYNC, ""); err != nil {
 				return fmt.Errorf("unable to mkdir ESP mountpoint: %w", err)
 			}
-			updateSvc.ProvideESP("/esp", p.ID, uint32(pn+1))
+			updateSvc.ProvideESP("/esp", uint32(pn+1), p)
 		case osimage.SystemAType:
 			if err := unix.Symlink(fmt.Sprintf("/dev/vda%d", pn+1), "/dev/system-a"); err != nil {
 				return fmt.Errorf("failed to symlink system-a: %w", err)
diff --git a/metropolis/node/core/update/update.go b/metropolis/node/core/update/update.go
index 92e2e88..107f9cc 100644
--- a/metropolis/node/core/update/update.go
+++ b/metropolis/node/core/update/update.go
@@ -14,13 +14,13 @@
 	"strconv"
 
 	"github.com/cenkalti/backoff/v4"
-	"github.com/google/uuid"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
 
 	"source.monogon.dev/metropolis/node/build/mkimage/osimage"
 	"source.monogon.dev/metropolis/pkg/blockdev"
 	"source.monogon.dev/metropolis/pkg/efivarfs"
+	"source.monogon.dev/metropolis/pkg/gpt"
 	"source.monogon.dev/metropolis/pkg/logtree"
 )
 
@@ -29,10 +29,11 @@
 type Service struct {
 	// Path to the mount point of the EFI System Partition (ESP).
 	ESPPath string
-	// UUID of the ESP System Partition.
-	ESPUUID uuid.UUID
+	// gpt.Partition of the ESP System Partition.
+	ESPPart *gpt.Partition
 	// Partition number (1-based) of the ESP in the GPT partitions array.
 	ESPPartNumber uint32
+
 	// Logger service for the update service.
 	Logger logtree.LeveledLogger
 }
@@ -84,10 +85,10 @@
 
 // ProvideESP is a convenience function for providing information about the
 // ESP after the update service has been instantiated.
-func (s *Service) ProvideESP(path string, partUUID uuid.UUID, partNum uint32) {
+func (s *Service) ProvideESP(path string, partNum uint32, part *gpt.Partition) {
 	s.ESPPath = path
 	s.ESPPartNumber = partNum
-	s.ESPUUID = partUUID
+	s.ESPPart = part
 }
 
 // CurrentlyRunningSlot returns the slot the current system is booted from.
@@ -146,7 +147,7 @@
 		switch p := e.FilePath[0].(type) {
 		case *efivarfs.HardDrivePath:
 			gptMatch, ok := p.PartitionMatch.(*efivarfs.PartitionGPT)
-			if ok && gptMatch.PartitionUUID != s.ESPUUID {
+			if ok && gptMatch.PartitionUUID != s.ESPPart.ID {
 				// Not related to our ESP
 				continue
 			}
@@ -166,9 +167,11 @@
 		Description: fmt.Sprintf("Metropolis Slot %s", slot),
 		FilePath: efivarfs.DevicePath{
 			&efivarfs.HardDrivePath{
-				PartitionNumber: s.ESPPartNumber,
+				PartitionNumber:     s.ESPPartNumber,
+				PartitionStartBlock: s.ESPPart.FirstBlock,
+				PartitionSizeBlocks: s.ESPPart.SizeBlocks(),
 				PartitionMatch: efivarfs.PartitionGPT{
-					PartitionUUID: s.ESPUUID,
+					PartitionUUID: s.ESPPart.ID,
 				},
 			},
 			efivarfs.FilePath(slot.EFIBootPath()),