Chapter 10. Freeing space on thinly-provisioned logical volumes using fstrim
You can manually run fstrim to return unused logical volume space to the thin pool so that it is available for other logical volumes.
Red Hat recommends running fstrim daily.
Prerequisites
Verify that the thin pool logical volume supports discard behavior.
Discard is supported if the output of the following command for the underlying device is not zero.
cat /sys/block/<device>/queue/discard_max_bytes
# cat /sys/block/<device>/queue/discard_max_bytesCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure
Run
fstrimto restore physical space to the thin pool.fstrim -v <mountpoint>
# fstrim -v <mountpoint>Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, the following command discards any unused space it finds on the logical volume mounted at
/gluster_bricks/data/data, and provides verbose output (-v).fstrim -v /gluster_bricks/data/data
# fstrim -v /gluster_bricks/data/dataCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
- See Scheduling a recurring job using cron for information on configuring an automatically recurring task.