You can perform a batch block discard operation to discard unused blocks on a mounted file system.
Before you begin
- The file system is mounted.
- The block device underlying the file system supports physical discard operations.
Procedure
-
Use the
fstrim utility:
- To perform discard only on a selected file system, use:
- To perform discard on all mounted file systems, use:
-
If you run the
fstrim command on:
- a device that does not support discard operations, or
- a logical device (LVM or MD) composed of multiple devices, where any one of the device does not support discard operations, the following message displays:
# fstrim /mnt/non_discard
fstrim: /mnt/non_discard: the discard operation is not supported