XFS

From Leo's Notes
Last edited on 3 January 2022, at 06:17.

XFS is a high performance filesystem.

Cheatsheet

Description Command Example
Create a XFS filesystem mkfs.xfs $device mkfs.xfs /dev/sda1
Check XFS filesystem xfs_check $device xfs_check /
Defragment a XFS filesystem xfs_fsr xfs_fsr /
Resize a XFS filesystem xfs_growfs $mount xfs_growfs /
Creates a XFS filesystem dump into a file xfsdump xfsdump -l 0 -f /backup-home.data /dev/mapper/vg_lv
Restore a XFS filesystem from a dump xfsrestore xfsrestore -f /backup-home.data /dev/mapper/vg_lv

Tasks

Growing a filesystem

Use xfs_growfs to expand a XFS filesystem to its maximum size of its underlying partition or device. This can be done while the filesystem is online.

# resize2fs /dev/mapper/cl_hpcmonitor-metrics
resize2fs 1.45.4 (23-Sep-2019)
Filesystem at /dev/mapper/cl_hpcmonitor-metrics is mounted on /var/metrics; on-line resizing required
old_desc_blocks = 83, new_desc_blocks = 89
The filesystem on /dev/mapper/cl_hpcmonitor-metrics is now 186122240 (4k) blocks long.

Shrinking a filesystem

You can't. You need to destroy and recreate the filesystem. You can use xfsdump and xfsrestore to help with this.

See also