What it does
XFS repairs itself after a crash by replaying its log at mount time. When the file system is really damaged (mount fails, kernel shows XFS corruption), run xfs_repair on the unmounted device. -n only checks. -L throws away the log — a last resort that can lose recent changes.
fsck.xfs exists but does nothing; use xfs_repair.
How to write it
xfs_repair [OPTION]... DEVICEOptions 14
Most used
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
1Check only
umount /data xfs_repair -n /dev/vgdata/lvdataExit code 1 = problems found.
2Repair
xfs_repair /dev/vgdata/lvdataThen mount again.
3Dirty log error
xfs_repair /dev/vgdata/lvdata ERROR: The filesystem has valuable metadata changes in a log which needs to be replayed. Mount the filesystem to replay the log, and unmount it before re-running xfs_repair.Mount and unmount first.
4Log cannot be replayed
xfs_repair -L /dev/vgdata/lvdataLast resort: recent changes in the log are lost.
5Root file system from a rescue disk
xfs_repair /dev/mapper/rhel-rootDo not mount it in the rescue environment first.
6Mounted? It refuses
xfs_repair /dev/vdb1 xfs_repair: /dev/vdb1 contains a mounted filesystemUnmount it.
7Find lost files after a repair
ls /data/lost+foundFiles without a folder end up here, named by inode number.
8Repair an image file
xfs_repair -f /var/tmp/disk.imgFor VM images or copies.
9Find kernel messages about corruption
"Metadata corruption detected" means: plan a repair.
10Low memory
xfs_repair -m 1024 /dev/vgdata/lvdataLimit memory use on small systems.
Nothing matches this filter.
Watch out
- Never repair a mounted file system.
- Make an image copy (dd) of important damaged disks before repairing.
Exit codes
0 | No problems (or repaired). |
1 | Problems found (with -n) or errors. |
2 | Dirty log: mount first. |
4 | Something was repaired (with -e). |