Can XFS be shrinked?

For example when customizing a pre-built OS with filesystems from a template to meet the storage available specific to your envrionment. It’s possible to use resize2fs to shrink an ext2/3/4 filesystem. But when talking about XFS, the thing is quite different — XFS cannot be shrinked!

What is format XFS?

XFS is a 64-bit journaling file system initially developed by Silicon Graphics. It is designed for parallel I/O based on allocation groups. This allows a system to scale based on the number of I/O threads and file system bandwidth. It is designed to span multiple storage devices.

Does XFS get fragmented?

On an XFS filesystem, containing a large number of small files (i.e. <= 4KiB in size), the adding and deleting of files can cause the free space to get fragmented. This fragmentation can cause a false “out of space” message despite there being a significant amount of free space available.

How do I reduce file size in XFS?

How to Reduce / Shrink the Size of a LVM Partition Formatted with XFS Filesystem?

  1. Backup the data using xfsdump.
  2. Unmount the filesystem.
  3. Shrink logical volume to desired size using lvreduce.
  4. Format the partition with xfs filesystem.
  5. Remount the filesystem.
  6. Restore the data using xfsrestore.

How do I resize XFS filesystem?

There is currently no command to shrink an XFS file system. You can use the xfs_growfs command to increase the size of a mounted XFS file system if there is space on the underlying devices to accommodate the change. The command does not have any effect on the layout or size of the underlying devices.

How does XFS file work?

XFS provides journaling for file system metadata, where file system updates are first written to a serial journal before the actual disk blocks are updated. The journal is a circular buffer of disk blocks that is not read in normal file system operation.