fsck.xfs - Linux
Overview
fsck.xfs is a utility used to check and repair inconsistencies in an XFS filesystem. It is commonly used during system boot to ensure the integrity of critical filesystems before the system becomes operational.
Syntax
fsck.xfs [-fnrvyp] [-x option] device
Options/Flags
- -f: Force a check even if the filesystem is not mounted.
- -n: Non-interactive mode.
- -r: Repair mode. Automatically fixes detected inconsistencies.
- -v: Verbose mode. Provides detailed progress information.
- -y: Assume "yes" to all prompts.
- -p: Parallel mode. Performs multiple checks simultaneously.
- -x option: Extended options:
- preen: Run in preen mode, skipping lengthy checks.
- eN: Enable additional checks.
Examples
Basic Usage:
fsck.xfs /dev/sda1
Repair Mode:
fsck.xfs -r /dev/sda1
Non-interactive Mode:
fsck.xfs -n /dev/sda1
Extended Check:
fsck.xfs -x e2 /dev/sda1
Common Issues
- FileSystem Not Found: Ensure the device or mount point is specified correctly.
- Permissions Denied: Make sure you have sufficient permissions to access the filesystem.
- Corrupt File System: If the filesystem is severely damaged, recovery may not be possible.
Integration
fsck.xfs can be integrated into scripts or automated tasks. For example:
#!/bin/bash
if fsck.xfs -n /dev/sda1; then
echo "Filesystem is clean"
else
echo "Filesystem is corrupted. Please repair it manually."
fi
Related Commands
- tunefs: Adjust filesystem parameters.
- xfs_repair: Advanced tool for repairing XFS filesystems.
- xfs_info: Display XFS filesystem information.