diff --git a/diskimage_builder/block_device/level1/partitioning.py b/diskimage_builder/block_device/level1/partitioning.py index 83e5b7bf..078fd6a7 100644 --- a/diskimage_builder/block_device/level1/partitioning.py +++ b/diskimage_builder/block_device/level1/partitioning.py @@ -206,7 +206,7 @@ class Partitioning(PluginBase): # now all the partitions are created, get device-mapper to # mount them if not os.path.exists("/.dockerenv"): - exec_sudo(["kpartx", "-avs", self.device_path]) + exec_sudo(["kpartx", "-uvs", self.device_path]) else: # If running inside Docker, make our nodes manually, # because udev will not be working. kpartx cannot run in diff --git a/diskimage_builder/block_device/tests/test_gpt.py b/diskimage_builder/block_device/tests/test_gpt.py index db046282..c3978db4 100644 --- a/diskimage_builder/block_device/tests/test_gpt.py +++ b/diskimage_builder/block_device/tests/test_gpt.py @@ -70,7 +70,7 @@ class TestGPT(tc.TestGraphGeneration): cmd_sequence = [ mock.call(parted_cmd), mock.call(['sync']), - mock.call(['kpartx', '-avs', '/dev/loopX']) + mock.call(['kpartx', '-uvs', '/dev/loopX']) ] self.assertEqual(mock_exec_sudo.call_count, len(cmd_sequence)) mock_exec_sudo.assert_has_calls(cmd_sequence) diff --git a/diskimage_builder/block_device/tests/test_lvm.py b/diskimage_builder/block_device/tests/test_lvm.py index fd45f170..757453af 100644 --- a/diskimage_builder/block_device/tests/test_lvm.py +++ b/diskimage_builder/block_device/tests/test_lvm.py @@ -512,7 +512,7 @@ class TestLVM(tc.TestGraphGeneration): mock.call.create_mbr(), # now mount partitions mock.call.sudo_part(['sync']), - mock.call.sudo_part(['kpartx', '-avs', '/dev/fake/image0']), + mock.call.sudo_part(['kpartx', '-uvs', '/dev/fake/image0']), # now create lvm environment mock.call.sudo_lvm(['pvcreate', '/dev/fake/root', '--force']), mock.call.sudo_lvm( diff --git a/releasenotes/notes/block-device-update-partition-table-eb4ff077f90dfb19.yaml b/releasenotes/notes/block-device-update-partition-table-eb4ff077f90dfb19.yaml new file mode 100644 index 00000000..a807c05e --- /dev/null +++ b/releasenotes/notes/block-device-update-partition-table-eb4ff077f90dfb19.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - Fix cases of 'mkfs' failing because the partitions never showed up. + Partition mappings will now be updated instead of just adding them with + 'kpartx'. That means that 'kpartx' will also remove devmappings for deleted + partitions.