Skip to content

Commit

Permalink
Set gpt partition as bootable if associated to system-boot role
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Mars <[email protected]>
  • Loading branch information
upils committed Jul 16, 2024
1 parent f80330d commit 1ddb7f8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/statemachine/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const (
schemaMBR = "mbr"
// schemaGPT identifies a GUID Partition Table partitioning schema
schemaGPT = "gpt"

gptBootableAttribute uint64 = 4
)

var runCmd = helper.RunCmd
Expand Down Expand Up @@ -538,12 +540,18 @@ func gptPartitionFromStruct(structure gadget.VolumeStructure, sectorSize uint64,
partitionName = "writable"
}

return &gpt.Partition{
partition := &gpt.Partition{
Start: uint64(math.Ceil(float64(*structure.Offset) / float64(sectorSize))),
Size: uint64(structure.Size),
Type: gpt.Type(structureType),
Name: partitionName,
}

if structure.Role == gadget.SystemBoot || structure.Label == gadget.SystemBoot {
partition.Attributes = gptBootableAttribute
}

return partition
}

// copyDataToImage runs dd commands to copy the raw data to the final image with appropriate offsets
Expand Down

0 comments on commit 1ddb7f8

Please sign in to comment.