Skip to content

Commit 6b8413c

Browse files
committed
partitioning: Add partattrs property to partition
Add a 'partattrs' property to partitions. It allows the GPT partition attribute bits to be set for a partition. Notably this is needed to set bits 48 and 56, which are part of the GUID specific range, to allow a ChromeOS Kernel partition to be booted on Chromebooks. Signed-off-by: Nícolas F. R. A. Prado <[email protected]>
1 parent 3a3ad05 commit 6b8413c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

actions/image_partition_action.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ a 32 bits hexadecimal number (e.g. '1234ABCD' without any dash separator).
5858
fsck: bool
5959
fsuuid: string
6060
partuuid: string
61+
partattrs: list of partition attributes
6162
6263
Mandatory properties:
6364
@@ -95,6 +96,16 @@ for partition.
9596
- flags -- list of additional flags for partition compatible with parted(8)
9697
'set' command.
9798
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+
98109
- fsck -- if set to `false` -- then set fs_passno (man fstab) to 0 meaning no filesystem
99110
checks in boot time. By default is set to `true` allowing checks on boot.
100111
@@ -187,6 +198,7 @@ type Partition struct {
187198
Name string
188199
PartLabel string
189200
PartType string
201+
PartAttrs []string
190202
PartUUID string
191203
Start string
192204
End string
@@ -531,6 +543,13 @@ func (i ImagePartitionAction) Run(context *debos.DebosContext) error {
531543
}
532544
}
533545

546+
if p.PartAttrs != nil {
547+
err = debos.Command{}.Run("sfdisk", "sfdisk", "--part-attrs", context.Image, fmt.Sprintf("%d", p.number), strings.Join(p.PartAttrs, ","))
548+
if err != nil {
549+
return err
550+
}
551+
}
552+
534553
/* PartUUID will only be set for gpt partitions */
535554
if len(p.PartUUID) > 0 {
536555
err = debos.Command{}.Run("sfdisk", "sfdisk", "--part-uuid", context.Image, fmt.Sprintf("%d", p.number), p.PartUUID)

0 commit comments

Comments
 (0)