Skip to content

Commit 67b94a7

Browse files
committed
disk_tools: Remove partitions reliably
Signed-off-by: Robert Baldyga <robert.baldyga@unvertical.com>
1 parent 09e1b4e commit 67b94a7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

test_tools/disk_tools.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#
22
# Copyright(c) 2019-2022 Intel Corporation
33
# Copyright(c) 2023-2025 Huawei Technologies Co., Ltd.
4+
# Copyright(c) 2026 Unvertical
45
# SPDX-License-Identifier: BSD-3-Clause
56
#
67

@@ -254,8 +255,11 @@ def remove_partitions(device):
254255

255256
TestRun.LOGGER.info(f"Removing partitions from device: {device.path} "
256257
f"({device.get_device_id()}).")
257-
wipefs(device)
258-
Udev.trigger()
258+
# We can't use wipefs here. wipefs only erases magic bytes, not the partition
259+
# table itself, so the kernel may still see stale partitions after partprobe.
260+
# parted mklabel replaces the entire partition table and triggers kernel re-read.
261+
# The label type choice does not really matter, so we just pick gpt.
262+
TestRun.executor.run_expect_success(f"parted --script {device.path} mklabel gpt")
259263
Udev.settle()
260264
output = TestRun.executor.run(f"ls {device.path}* -1")
261265
if len(output.stdout.split('\n')) > 1:

0 commit comments

Comments
 (0)