1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-14 05:57:40 +03:00

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.
This commit is contained in:
Lennart Poettering 2020-07-30 22:22:21 +02:00
parent 5b5109e225
commit f0cb1b951c

View File

@ -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;