From 942b272ba17a152b85f994a5322c30636945ae91 Mon Sep 17 00:00:00 2001 From: Paul Mars Date: Thu, 17 Oct 2024 11:44:47 +0200 Subject: [PATCH] i/partition: Set bootable attribute on GPT partition Signed-off-by: Paul Mars --- internal/partition/partition.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/partition/partition.go b/internal/partition/partition.go index c7880f45..61094672 100644 --- a/internal/partition/partition.go +++ b/internal/partition/partition.go @@ -21,6 +21,8 @@ const ( // SchemaGPT identifies a GUID Partition Table partitioning schema SchemaGPT = "gpt" + gptBootableAttribute uint64 = 4 + sectorSize512 uint64 = 512 sectorSize4k uint64 = 4096 @@ -167,12 +169,18 @@ func (t *GPTTable) AddPartition(structurePair *gadget.OnDiskAndGadgetStructurePa partitionName = "writable" } - t.concreteTable.Partitions = append(t.concreteTable.Partitions, &gpt.Partition{ + p := &gpt.Partition{ Start: startSector, Size: size, Type: gpt.Type(structureType), Name: partitionName, - }) + } + + if helper.IsSystemBootStructure(structurePair.GadgetStructure) { + p.Attributes = gptBootableAttribute + } + + t.concreteTable.Partitions = append(t.concreteTable.Partitions, p) return nil }