diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-07-30 22:22:21 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-08-24 22:00:31 +0200 |
commit | f0cb1b951caeec68d4c892c7d02e6829f6f95a48 (patch) | |
tree | 7ccf985b6596ecc3a23357e1bd86d82b266109bf /src/partition | |
parent | repart: talk about future partitions (diff) | |
download | systemd-f0cb1b951caeec68d4c892c7d02e6829f6f95a48.tar.xz systemd-f0cb1b951caeec68d4c892c7d02e6829f6f95a48.zip |
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.
Diffstat (limited to 'src/partition')
-rw-r--r-- | src/partition/repart.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c index e8d6302296..cbb10f7475 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; |