How to reduce XFS file system
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
- A RFE was filed, requesting the ability to shrink a XFS filesystem in RHEL 7 in the following Red Hat Bugzilla
- This content is not included.Bug 1062667 - [RFE] Add ability to shrink XFS filesystems, however, this RFE was CLOSED as WONTFIX due to design constraints.
- At the moment, functionality to shrink XFS filesystems is not available in RHEL in a supported manner. As a TechPreview, with a few limitations, RHEL10 offers a shrink functionality for XFS. For more information, please see RHEL10 Release Notes - Technology Previews for filesystems and storage section
Workarounds
In some cases, the following workarounds may be acceptable:
- Use some backup/restore solution, such as
xfsdumpandxfsrestore. This may be useful especially if the filesystem is mostly empty. - Use the
xfs_quotacommand to implement project (directory tree) quotas. Project quotas implement space limitations for all files within a directorysubtree,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
-
This limitation is mentioned in product documentation, Check the NOTE section from product documentation here How to resize XFS filesytem.
-
Also, refer the upstream link which gives more information about Content from xfs.org is not included.Shrinking Support of XFS Filesystem.
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.