Using fstrim to Discard Unused Blocks

WARNING:

This documentation is a draft and is not meant for production use. Branch: OL10-FSADMIN

The fstrim command is used to discard unused blocks on a file system, which can improve performance and reduce wear on storage devices based on flash technology, such as solid-state drives (SSDs) and NVMe.

The fstrim command only works on file systems and devices that can support the feature. If you run the command for a device that doesn't include the discard feature, an error message is returned.

  • To perform a discard on a selected file system, provide the fstrim command with the path to the mount point of the file system.

    For example run:

    sudo fstrim /mnt
  • You can perform a discard on all mounted file systems by using the --all option:
    sudo fstrim --all