Skip to content

Commit

Permalink
i/partition: Set bootable attribute on GPT partition
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Mars <[email protected]>
  • Loading branch information
upils committed Oct 17, 2024
1 parent 92946dc commit 4358120
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/partition/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const (
// SchemaGPT identifies a GUID Partition Table partitioning schema
SchemaGPT = "gpt"

gptBootableAttribute uint64 = 4

sectorSize512 uint64 = 512
sectorSize4k uint64 = 4096

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 4358120

Please sign in to comment.