-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
image-hd: add forced-primary flag for higher MBR layout flexibility
The current limitation of Genimage is that it is not able to create MBR images that have primary partitions that start after a logical partition. This can be useful for images that can be later resized based on the actual device size - for this operation the partition must be at the end of the device, and if it is present in a logical partition, it must be resized first, making it a two-step process. This commit adds the "forced-primary" flag which can be used to indicate that the partition should be put into the disk's MBR instead of creating another logical partition. Validation ensures that this syntax allows to create such partitions only after an existing logical partition, and that the maximum number of MBR entries woudn't be exceeded by doing so. Test cases for valid and invalid configuiration has been added. Also added few more details in the debug print to make it more obvious how the MBR/EBR layout looks like. Signed-off-by: Jan Čermák <[email protected]>
- Loading branch information
Showing
11 changed files
with
251 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
image test.hdimage { | ||
hdimage { | ||
align = 1M | ||
extended-partition = 3 | ||
} | ||
partition primary1 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition primary2 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition extended1 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition extended2 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition primary3 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
forced-primary = "yes" | ||
} | ||
partition primary4 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
/* would be 5th primary partition */ | ||
forced-primary = "yes" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
image test.hdimage { | ||
hdimage { | ||
align = 1M | ||
extended-partition = 1 | ||
} | ||
partition extended1 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition extended2 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition extended3 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition extended4 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition primary2 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
forced-primary = "yes" | ||
} | ||
partition extended5 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
/* extended partition would overlap the forced-primary one */ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
image test.hdimage { | ||
hdimage { | ||
align = 1M | ||
extended-partition = 1 | ||
} | ||
partition part1 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
forced-primary = "yes" | ||
/* forced-primary can be only used for partitions defined after the extended partition */ | ||
} | ||
partition part2 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition part3 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition part4 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition part5 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
image test.hdimage { | ||
hdimage { | ||
align = 1M | ||
} | ||
partition primary1 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition primary2 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition primary3 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition primary4 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition primary5 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
/* part4 is implicitly extended -> too many primary entries */ | ||
forced-primary = "yes" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
image test.hdimage { | ||
hdimage { | ||
align = 1M | ||
disk-signature = 0x12345678 | ||
extended-partition = 2 | ||
} | ||
partition part1 { | ||
image = "part1.img" | ||
partition-type = 0xc | ||
bootable = "yes" | ||
} | ||
/* | ||
* partition 2 will be the extended partition entry | ||
* partitions 3-4 will be primary partitions at the end | ||
* partition 5 is first logical partition of the extended partition | ||
*/ | ||
partition part5-logical { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition part6-logical { | ||
image = "part2.img" | ||
partition-type = 0x83 | ||
} | ||
partition part7-logical { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition part8-logical { | ||
image = "part2.img" | ||
partition-type = 0x83 | ||
} | ||
partition part9-logical { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
} | ||
partition part3 { | ||
image = "part1.img" | ||
partition-type = 0x83 | ||
forced-primary = "yes" | ||
} | ||
partition part4 { | ||
image = "part2.img" | ||
partition-type = 0x82 | ||
forced-primary = "yes" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Disk identifier: 0x12345678 | ||
images/test.hdimage1:start=2048,size=2048,type=c,bootable | ||
images/test.hdimage2:start=4096,size=20480,type=f | ||
images/test.hdimage3:start=24576,size=2048,type=83 | ||
images/test.hdimage4:start=26624,size=2048,type=82 | ||
images/test.hdimage5:start=6144,size=2048,type=83 | ||
images/test.hdimage6:start=10240,size=2048,type=83 | ||
images/test.hdimage7:start=14336,size=2048,type=83 | ||
images/test.hdimage8:start=18432,size=2048,type=83 | ||
images/test.hdimage9:start=22528,size=2048,type=83 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters