How to reduce XFS file system

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 10
  • Red Hat Enterprise Linux 9
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 6 (with the Scalable File System Add-on)
  • Red Hat Enterprise Linux 5.6+ (with the Scalable File System Add-on)
  • XFS Filesystem
  • Logical Volume Management (LVM)

Issue

  • How to reduce the size a partition formatted with XFS Filesystem?
  • How can I reduce the size a LVM partition formatted with XFS Filesystem?

Resolution

Workarounds

In some cases, the following workarounds may be acceptable:

  • Use some backup/restore solution, such as xfsdump and xfsrestore. This may be useful especially if the filesystem is mostly empty.
  • Use the xfs_quota command to implement project (directory tree) quotas. Project quotas implement space limitations for all files within a directory subtree, similar to behavior under a new filesystem mount point.
  • If it's possible that you might want to shrink the file system, you might consider to use a different supported file system which has this feature directly when creating the file system, like ext4.

Root Cause

While the XFS file systems can be grown while mounted, their size cannot be reduced. This feature has been discussed on the Content from xfs.org is not included.upstream XFS mailing lists for over 10 years, but the feature is deemed to be complex and risky, and limited critical use cases are believed to exist.

Diagnostic Steps

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.