@@ -58,6 +58,7 @@ a 32 bits hexadecimal number (e.g. '1234ABCD' without any dash separator).
58
58
fsck: bool
59
59
fsuuid: string
60
60
partuuid: string
61
+ partattrs: list of partition attribute bits to set
61
62
62
63
Mandatory properties:
63
64
@@ -95,6 +96,16 @@ for partition.
95
96
- flags -- list of additional flags for partition compatible with parted(8)
96
97
'set' command.
97
98
99
+ - partattrs -- list of GPT partition attribute bits to set, as defined in
100
+ https://uefi.org/specs/UEFI/2.10/05_GUID_Partition_Table_Format.html#defined-gpt-partition-entry-attributes.
101
+ Bit 0: "Required Partition", bit 1: "No Block IO Protocol", bit 2: "Legacy BIOS
102
+ Bootable". Bits 3-47 are reserved. Bits 48 - 63 are GUID specific. For example,
103
+ ChromeOS Kernel partitions (GUID=fe3a2a5d-4f32-41a7-b725-accc3285a309) use bit
104
+ 56 for "successful boot" and bits 48-51 for "priority", where 0 means not
105
+ bootable, thus bits 56 and 48 need to be set through this property in order to
106
+ be able to boot a ChromeOS Kernel partition on a Chromebook, like so:
107
+ 'partattrs: [56, 48]'.
108
+
98
109
- fsck -- if set to `false` -- then set fs_passno (man fstab) to 0 meaning no filesystem
99
110
checks in boot time. By default is set to `true` allowing checks on boot.
100
111
@@ -175,6 +186,7 @@ import (
175
186
"path/filepath"
176
187
"sort"
177
188
"strings"
189
+ "strconv"
178
190
"syscall"
179
191
"time"
180
192
"regexp"
@@ -187,6 +199,7 @@ type Partition struct {
187
199
Name string
188
200
PartLabel string
189
201
PartType string
202
+ PartAttrs []string
190
203
PartUUID string
191
204
Start string
192
205
End string
@@ -531,6 +544,13 @@ func (i ImagePartitionAction) Run(context *debos.DebosContext) error {
531
544
}
532
545
}
533
546
547
+ if p .PartAttrs != nil && len (p .PartAttrs ) > 0 {
548
+ err = debos.Command {}.Run ("sfdisk" , "sfdisk" , "--part-attrs" , context .Image , fmt .Sprintf ("%d" , p .number ), strings .Join (p .PartAttrs , "," ))
549
+ if err != nil {
550
+ return err
551
+ }
552
+ }
553
+
534
554
/* PartUUID will only be set for gpt partitions */
535
555
if len (p .PartUUID ) > 0 {
536
556
err = debos.Command {}.Run ("sfdisk" , "sfdisk" , "--part-uuid" , context .Image , fmt .Sprintf ("%d" , p .number ), p .PartUUID )
@@ -792,6 +812,13 @@ func (i *ImagePartitionAction) Verify(context *debos.DebosContext) error {
792
812
}
793
813
}
794
814
815
+ for _ , bitStr := range p .PartAttrs {
816
+ bit , err := strconv .ParseInt (bitStr , 0 , 0 )
817
+ if err != nil || bit < 0 || bit > 2 && bit < 48 || bit > 63 {
818
+ return fmt .Errorf ("Partition attribute bit '%s' outside of valid range (0-2, 48-63)" , bitStr )
819
+ }
820
+ }
821
+
795
822
if p .Start == "" {
796
823
return fmt .Errorf ("Partition %s missing start" , p .Name )
797
824
}
0 commit comments