diff --git a/partitioning/gpt/gpt.go b/partitioning/gpt/gpt.go index bf7c4ed..5365b14 100644 --- a/partitioning/gpt/gpt.go +++ b/partitioning/gpt/gpt.go @@ -558,7 +558,6 @@ func (t *Table) writePMBR() error { // boot signature protectiveMBR[510], protectiveMBR[511] = 0x55, 0xAA - protectiveMBR[511] = 0xAA // PMBR protective entry. b := protectiveMBR[446 : 446+16] diff --git a/partitioning/gpt/gpt_test.go b/partitioning/gpt/gpt_test.go index 8b1a7a7..222ee4b 100644 --- a/partitioning/gpt/gpt_test.go +++ b/partitioning/gpt/gpt_test.go @@ -138,6 +138,7 @@ func TestGPT(t *testing.T) { ))) require.NoError(t, allocateError(table.AllocatePartition(100*MiB, "100M", partType1, gpt.WithUniqueGUID(uuid.MustParse("3D0FE86B-7791-4659-B564-FC49A542866D")), + gpt.WithLegacyBIOSBootableAttribute(true), ))) require.NoError(t, allocateError(table.AllocatePartition(2.5*GiB, "2.5G", partType2, gpt.WithUniqueGUID(uuid.MustParse("EE1A711E-DE12-4D9F-98FF-672F7AD638F8")), diff --git a/partitioning/gpt/options.go b/partitioning/gpt/options.go index fce0091..d49e76c 100644 --- a/partitioning/gpt/options.go +++ b/partitioning/gpt/options.go @@ -66,3 +66,12 @@ func WithUniqueGUID(guid uuid.UUID) PartitionOption { o.UniqueGUID = guid } } + +// WithLegacyBIOSBootableAttribute marks the partition as bootable. +func WithLegacyBIOSBootableAttribute(val bool) PartitionOption { + return func(args *PartitionOptions) { + if val { + args.Flags |= (1 << 2) + } + } +} diff --git a/partitioning/gpt/testdata/allocate.sfdisk b/partitioning/gpt/testdata/allocate.sfdisk index 2242f18..a29f37e 100644 --- a/partitioning/gpt/testdata/allocate.sfdisk +++ b/partitioning/gpt/testdata/allocate.sfdisk @@ -6,6 +6,6 @@ last-lba: 12582878 sector-size: 512 start= 2048, size= 2097152, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=DA66737E-1ED4-4DDF-B98C-70CEBFE3ADA0, name="1G" -start= 2099200, size= 204800, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=3D0FE86B-7791-4659-B564-FC49A542866D, name="100M" +start= 2099200, size= 204800, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=3D0FE86B-7791-4659-B564-FC49A542866D, name="100M", attrs="LegacyBIOSBootable" start= 2304000, size= 5242880, type=E6D6D379-F507-44C2-A23C-238F2A3DF928, uuid=EE1A711E-DE12-4D9F-98FF-672F7AD638F8, name="2.5G" start= 7546880, size= 2097152, type=E6D6D379-F507-44C2-A23C-238F2A3DF928, uuid=15E609C8-9775-4E86-AF59-8A87E7C03FAB, name="1G"