From 9e0b115e0cfcbd0fe97df40dddc11b0946a1d93b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 8 Oct 2021 12:39:40 +0200 Subject: [PATCH] mkosi: discard partition block devices before writing into them with dd's 'sparse' option Otherwise there might be the GPT footer lingering in the partition. --- mkosi/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 5b8bb7dfb..fb30e7bef 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -3551,6 +3551,9 @@ def insert_partition( with cm as dev: path = dev if dev is not None else part.blockdev(loopdev) + # Let's discard the partition block device first, to ensure the GPT partition table footer that + # likely is stored in it is flushed out. After all we want to write with dd's sparse option. + run(["blkdiscard", path]) run(["dd", f"if={blob.name}", f"of={path}", "conv=nocreat,sparse"]) return blob_size -- 2.47.3