Allow users to specify partition type in the MBR PTE

The MBR Partition Table Entry (PTE) allows one to specify many
possible partition types and one of the benefits of this is being able
to specify the CHS variant or the LBA variant.

By default, LBA only creates partitions of type 0x83 (of course,
that's only because the documentation doesn't tell you how to make it
do anything else).

I will take up Ian's suggestion in patch set 2 for a more rigorous
test in an independent patch set.

Change-Id: If3068535980eac2e58d4025444c65147a8c7fedc
Closes-Bug:#1703352
This commit is contained in:
Amrith Kumar 2017-07-10 23:22:29 -04:00
parent 43e32116bd
commit 52faa0e1d9
2 changed files with 15 additions and 0 deletions

View file

@ -162,3 +162,13 @@ class TestMBR(tb.TestBase):
"9 155648 176127 0x83 0x0 dos\n"
"10 178176 198655 0x83 0x0 dos\n"
"11 200704 221183 0x83 0x0 dos\n", output)
def test_pri_fat32_lba_partition(self):
"""Creates a partition with a non-default 'type' and verifies."""
with MBR(self.image_path, TestMBR.disk_size_1G, 1024 * 1024) as mbr:
mbr.add_partition(True, False, TestMBR.disk_size_10M, 0x0c)
output = self._run_partx(self.image_path)
self.assertEqual(
"1 2048 22527 0xc 0x0 dos\n", output)

View file

@ -323,6 +323,11 @@ size
(percentage) numbers: in the later case the size is calculated
based on the remaining free space.
type (optional)
The partition type stored in the MBR partition table entry. The
default value is '0x83' (Linux Default partition). Any valid one
byte hexadecimal value may be specified here.
Example:
.. code-block:: yaml