From f0cb1b951caeec68d4c892c7d02e6829f6f95a48 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 30 Jul 2020 22:22:21 +0200 Subject: [PATCH] repart: wipe partition first, then discard Wiping means writing zero sectors to disk. Hence it's better to do this before we discard, so that the zeroes we use to overwrite are properly discarded. If we'd do it the other way round we'd discard the data and then reallocte it just to write zeroes. --- src/partition/repart.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/partition/repart.c b/src/partition/repart.c index e8d6302296f..cbb10f74757 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -2193,17 +2193,15 @@ static int context_wipe_and_discard(Context *context, bool from_scratch) { if (!p->allocated_to_area) continue; - if (!from_scratch) { - r = context_discard_partition(context, p); - if (r < 0) - return r; - } - r = context_wipe_partition(context, p); if (r < 0) return r; if (!from_scratch) { + r = context_discard_partition(context, p); + if (r < 0) + return r; + r = context_discard_gap_after(context, p); if (r < 0) return r; -- 2.47.3