From 52faa0e1d94498567f7d4492058b85f5b0aa0af0 Mon Sep 17 00:00:00 2001 From: Amrith Kumar Date: Mon, 10 Jul 2017 23:22:29 -0400 Subject: [PATCH] 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 --- diskimage_builder/block_device/tests/test_mbr.py | 10 ++++++++++ doc/source/user_guide/building_an_image.rst | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/diskimage_builder/block_device/tests/test_mbr.py b/diskimage_builder/block_device/tests/test_mbr.py index 606b943ed..0645ee515 100644 --- a/diskimage_builder/block_device/tests/test_mbr.py +++ b/diskimage_builder/block_device/tests/test_mbr.py @@ -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) diff --git a/doc/source/user_guide/building_an_image.rst b/doc/source/user_guide/building_an_image.rst index 15bb9586a..7f7a30814 100644 --- a/doc/source/user_guide/building_an_image.rst +++ b/doc/source/user_guide/building_an_image.rst @@ -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