From b4015b7dba40190b0d974e79f04ce3b8d0b7803d Mon Sep 17 00:00:00 2001 From: Neal Gompa Date: Jul 15 2021 09:26:39 +0000 Subject: Force the filesystem to sync to disk before trimming This ensures that data discard works properly. Fixes: bc7e8ce561c2b1ec5536bd7a3e77226dbeab538d Signed-off-by: Neal Gompa --- diff --git a/fedora-cloud-base.ks b/fedora-cloud-base.ks index 6ff9c89..74c3d94 100644 --- a/fedora-cloud-base.ks +++ b/fedora-cloud-base.ks @@ -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.