Force the filesystem to sync to disk before trimming

This ensures that data discard works properly.

Fixes: bc7e8ce561

Signed-off-by: Neal Gompa <ngompa@fedoraproject.org>
This commit is contained in:
Neal Gompa 2021-07-15 05:26:39 -04:00
parent ad8e04aacb
commit b4015b7dba
1 changed files with 4 additions and 1 deletions

View File

@ -124,8 +124,11 @@ rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
echo "Zeroing out empty space."
# This forces the filesystem to reclaim space from deleted files
dd bs=1M if=/dev/zero of=/var/tmp/zeros || :
rm -f /var/tmp/zeros
echo "(Don't worry -- that out-of-space error was expected.)"
# Force sync to disk (Cf. https://pagure.io/cloud-sig/issue/340#comment-743430)
btrfs filesystem sync /
rm -f /var/tmp/zeros
btrfs filesystem sync /
# When we build the image a networking config file gets left behind.
# Let's clean it up.