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
- An 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 <= RHEL 10 in a supported manner.
- As a TechPreview, with limited functionality, RHEL 10 offers a shrink functionality for XFS. For more information, please see RHEL 10 Release Notes - Technology Previews for filesystems and storage section.
- An RFE to add the ability to shrink an XFS filesystem online has been filed and is tracked in Jira Content from redhat.atlassian.net is not included.RHEL-22275. If this feature is required, please open a This content is not included.new support case on the Red Hat Customer Portal referring to this solution.
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.
As the maturaty of the XFS filesytem has evolved in the meatime Red Hat Engineering is reviewing options do implement this functionality in the future. This however is no commintment or guarantee that this feature will be shipped.
Diagnostic Steps
-
This limitation is mentioned in product documentation, Check the NOTE section from product documentation here This content is not included.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.