Merge ~mwhudson/curtin:msftres into curtin:master

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: bb9896dda3ddcbd6bcff603ebdf74e6cd638aa86
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~mwhudson/curtin:msftres
Merge into: curtin:master
Prerequisite: ~mwhudson/curtin:ptable_uuid_to_flag_entry-retval
Diff against target: 91 lines (+22/-7)
4 files modified
curtin/commands/block_meta.py (+3/-2)
curtin/storage_config.py (+1/-0)
doc/topics/storage.rst (+5/-5)
tests/integration/test_block_meta.py (+13/-0)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Dan Bungert Approve
Review via email: mp+444329@code.launchpad.net

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).

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Dan Bungert (dbungert) wrote :

Thanks!

review: Approve
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/curtin/commands/block_meta.py b/curtin/commands/block_meta.py
2index 314d2c7..34acd75 100644
3--- a/curtin/commands/block_meta.py
4+++ b/curtin/commands/block_meta.py
5@@ -52,6 +52,7 @@ SGDISK_FLAGS = {
6 "home": '8302',
7 "linux": '8300',
8 "lvm": '8e00',
9+ "msftres": '0c01',
10 "prep": '4100',
11 "raid": 'fd00',
12 "swap": '8200',
13@@ -921,8 +922,8 @@ def verify_size(devpath, expected_size_bytes, part_info):
14
15
16 def verify_ptable_flag(devpath, expected_flag, label, part_info):
17- if (expected_flag not in SGDISK_FLAGS.keys()) and (expected_flag not in
18- MSDOS_FLAGS.keys()):
19+ if expected_flag not in SGDISK_FLAGS and \
20+ expected_flag not in MSDOS_FLAGS:
21 raise RuntimeError(
22 'Cannot verify unknown partition flag: %s' % expected_flag)
23
24diff --git a/curtin/storage_config.py b/curtin/storage_config.py
25index 1e9b696..329183a 100644
26--- a/curtin/storage_config.py
27+++ b/curtin/storage_config.py
28@@ -24,6 +24,7 @@ GPT_GUID_TO_CURTIN_MAP = {
29 '9E1A2D38-C612-4316-AA26-8B49521E5A8B': 'prep',
30 'A19D880F-05FC-4D3B-A006-743F0F84911E': 'raid',
31 '0657FD6D-A4AB-43C4-84E5-0933C84B4F4F': 'swap',
32+ 'E3C9E316-0B5C-4DB8-817D-F92DF00215AE': 'msftres',
33 }
34
35 # MBR types
36diff --git a/doc/topics/storage.rst b/doc/topics/storage.rst
37index ba1ff73..918f3cd 100644
38--- a/doc/topics/storage.rst
39+++ b/doc/topics/storage.rst
40@@ -423,7 +423,7 @@ disks.
41 prior to creating the partition to ensure that other block layers or devices
42 do not enable themselves and prevent accessing the partition.
43
44-**flag**: *logical, extended, boot, bios_grub, swap, lvm, raid, home, prep*
45+**flag**: *logical, extended, boot, bios_grub, swap, lvm, raid, home, prep, msftres*
46
47 If the ``flag`` key is present, curtin will set the specified flag on the
48 partition. Note that some flags only apply to msdos partition tables, and some
49@@ -434,9 +434,9 @@ on a msdos table. An extended partition should be created containing all of the
50 empty space on the drive, and logical partitions can be created within it. A
51 extended partition must already be present to create logical partitions.
52
53-On msdos partition tables, the *boot* flag sets the boot parameter to that
54-partition. On gpt partition tables, the boot flag sets the esp flag on the
55-partition.
56+On msdos partition tables, the *boot* flag sets the boot parameter to
57+that partition. On gpt partition tables, the boot flag sets partition
58+type guid to the appropriate value for the EFI System Partition / ESP.
59
60 If the host system for curtin has been booted using UEFI then curtin will
61 install grub to the esp partition. If the system installation media
62@@ -450,7 +450,7 @@ filesystem or be mounted anywhere on the system.
63 **partition_type**: *msdos: byte value in 0xnn style; gpt: GUID*
64
65 Only applicable to v2 storage configuration. If both ``partition_type`` and
66-``flag`` are set, ``partition_type`` dictates the acutal type.
67+``flag`` are set, ``partition_type`` dictates the actual type.
68
69 The ``partition_type`` field allows for setting arbitrary partition type values
70 that do not have a matching ``flag``, or cases that are not handled by the
71diff --git a/tests/integration/test_block_meta.py b/tests/integration/test_block_meta.py
72index a2368e8..acd12e1 100644
73--- a/tests/integration/test_block_meta.py
74+++ b/tests/integration/test_block_meta.py
75@@ -1283,3 +1283,16 @@ table-length: 256'''.encode()
76 self.assertPartitions(
77 PartData(number=1, offset=1 << 20, size=1 << 20, boot=False,
78 partition_type='82'))
79+
80+ @parameterized.expand(((1,), (2,)))
81+ def test_msftres(self, sv):
82+ self.img = self.tmp_path('image.img')
83+ config = StorageConfigBuilder(version=sv)
84+ config.add_image(path=self.img, create=True, size='20M',
85+ ptable='gpt')
86+ config.add_part(number=1, offset=1 << 20, size=1 << 20, flag='msftres')
87+ self.run_bm(config.render())
88+
89+ self.assertPartitions(
90+ PartData(number=1, offset=1 << 20, size=1 << 20, boot=False,
91+ partition_type='E3C9E316-0B5C-4DB8-817D-F92DF00215AE'))

Subscribers

People subscribed via source and target branches