]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Explicitly adding partition after creating
authorMichael A Cassaniti <michael@cassaniti.id.au>
Mon, 18 Jul 2022 03:55:12 +0000 (13:55 +1000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 18 Jul 2022 16:21:27 +0000 (18:21 +0200)
This resolves an exception when the partition is explicitly removed later

mkosi/__init__.py

index d13a314530bbeb36e077866679383c2dfb4284dd..1f3b939571343b48139fe1edf988ba2df57d7dcb 100644 (file)
@@ -3954,6 +3954,15 @@ def insert_partition(
     with complete_step(f"Inserting partition of {format_bytes(part_size)}{ss}..."):
         args.partition_table.run_sfdisk(loopdev)
 
+        # Required otherwise the partition removal will fail
+        with open(loopdev, 'rb+') as f:
+            ioctl_partition_add(
+                f.fileno(),
+                part.number,
+                args.partition_table.partition_offset(part),
+                args.partition_table.partition_size(part)
+            )
+
     with complete_step("Writing partition..."):
         if ident == PartitionIdentifier.root:
             luks_format_root(args, loopdev, False, False, True)