curtin-dev team mailing list archive
-
curtin-dev team
-
Mailing list archive
-
Message #02943
[Merge] ~mwhudson/curtin:msftres into curtin:master
Michael Hudson-Doyle has proposed merging ~mwhudson/curtin:msftres into curtin:master with ~mwhudson/curtin:ptable_uuid_to_flag_entry-retval as a prerequisite.
Commit message:
support "msftres" as a (GPT-only) partition flag
We want to mark the recovery / reset partition as a "Microsoft Reserved
Partition" as GUI disk utilities hide such partitions, so add support
for this as a value for a partition flag. I chose "msftres" because
that's what parted calls this (although it maps msftres to type code
0x27 for a DOS partition table, which I think is wrong so I'm not doing
that).
Requested reviews:
curtin developers (curtin-dev)
For more details, see:
https://code.launchpad.net/~mwhudson/curtin/+git/curtin/+merge/444329
--
Your team curtin developers is requested to review the proposed merge of ~mwhudson/curtin:msftres into curtin:master.
diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
index 9499907..30110b6 100644
--- a/curtin/commands/block_meta.py
+++ b/curtin/commands/block_meta.py
@@ -52,6 +52,7 @@ SGDISK_FLAGS = {
"home": '8302',
"linux": '8300',
"lvm": '8e00',
+ "msftres": '0c01',
"prep": '4100',
"raid": 'fd00',
"swap": '8200',
@@ -921,8 +922,8 @@ def verify_size(devpath, expected_size_bytes, part_info):
def verify_ptable_flag(devpath, expected_flag, label, part_info):
- if (expected_flag not in SGDISK_FLAGS.keys()) and (expected_flag not in
- MSDOS_FLAGS.keys()):
+ if expected_flag not in SGDISK_FLAGS and \
+ expected_flag not in MSDOS_FLAGS:
raise RuntimeError(
'Cannot verify unknown partition flag: %s' % expected_flag)
diff --git a/curtin/storage_config.py b/curtin/storage_config.py
index 1f0c8ea..5a303c7 100644
--- a/curtin/storage_config.py
+++ b/curtin/storage_config.py
@@ -24,6 +24,7 @@ GPT_GUID_TO_CURTIN_MAP = {
'9E1A2D38-C612-4316-AA26-8B49521E5A8B': 'prep',
'A19D880F-05FC-4D3B-A006-743F0F84911E': 'raid',
'0657FD6D-A4AB-43C4-84E5-0933C84B4F4F': 'swap',
+ 'E3C9E316-0B5C-4DB8-817D-F92DF00215AE': 'msftres',
}
# MBR types
diff --git a/doc/topics/storage.rst b/doc/topics/storage.rst
index ba1ff73..918f3cd 100644
--- a/doc/topics/storage.rst
+++ b/doc/topics/storage.rst
@@ -423,7 +423,7 @@ disks.
prior to creating the partition to ensure that other block layers or devices
do not enable themselves and prevent accessing the partition.
-**flag**: *logical, extended, boot, bios_grub, swap, lvm, raid, home, prep*
+**flag**: *logical, extended, boot, bios_grub, swap, lvm, raid, home, prep, msftres*
If the ``flag`` key is present, curtin will set the specified flag on the
partition. Note that some flags only apply to msdos partition tables, and some
@@ -434,9 +434,9 @@ on a msdos table. An extended partition should be created containing all of the
empty space on the drive, and logical partitions can be created within it. A
extended partition must already be present to create logical partitions.
-On msdos partition tables, the *boot* flag sets the boot parameter to that
-partition. On gpt partition tables, the boot flag sets the esp flag on the
-partition.
+On msdos partition tables, the *boot* flag sets the boot parameter to
+that partition. On gpt partition tables, the boot flag sets partition
+type guid to the appropriate value for the EFI System Partition / ESP.
If the host system for curtin has been booted using UEFI then curtin will
install grub to the esp partition. If the system installation media
@@ -450,7 +450,7 @@ filesystem or be mounted anywhere on the system.
**partition_type**: *msdos: byte value in 0xnn style; gpt: GUID*
Only applicable to v2 storage configuration. If both ``partition_type`` and
-``flag`` are set, ``partition_type`` dictates the acutal type.
+``flag`` are set, ``partition_type`` dictates the actual type.
The ``partition_type`` field allows for setting arbitrary partition type values
that do not have a matching ``flag``, or cases that are not handled by the
diff --git a/tests/integration/test_block_meta.py b/tests/integration/test_block_meta.py
index a2368e8..acd12e1 100644
--- a/tests/integration/test_block_meta.py
+++ b/tests/integration/test_block_meta.py
@@ -1283,3 +1283,16 @@ table-length: 256'''.encode()
self.assertPartitions(
PartData(number=1, offset=1 << 20, size=1 << 20, boot=False,
partition_type='82'))
+
+ @parameterized.expand(((1,), (2,)))
+ def test_msftres(self, sv):
+ self.img = self.tmp_path('image.img')
+ config = StorageConfigBuilder(version=sv)
+ config.add_image(path=self.img, create=True, size='20M',
+ ptable='gpt')
+ config.add_part(number=1, offset=1 << 20, size=1 << 20, flag='msftres')
+ self.run_bm(config.render())
+
+ self.assertPartitions(
+ PartData(number=1, offset=1 << 20, size=1 << 20, boot=False,
+ partition_type='E3C9E316-0B5C-4DB8-817D-F92DF00215AE'))
Follow ups