fsck
Overview
The fsck
(File System Check) command checks and optionally repairs Linux filesystems. It’s a front-end for filesystem-specific checkers (fsck.fstype).
Syntax
fsck [options] [-t type] [filesystem...]
Common Options
Option | Description |
---|---|
-A |
Check all filesystems |
-C |
Display progress bar |
-f |
Force check |
-M |
Skip mounted |
-N |
Don’t execute |
-P |
Parallel check |
-R |
Skip root filesystem |
-T |
Don’t show title |
-V |
Verbose |
-y |
Assume yes |
Exit Codes
Code | Description |
---|---|
0 | No errors |
1 | Filesystem fixed |
2 | System should be rebooted |
4 | Filesystem errors left |
8 | Operational error |
16 | Usage or syntax error |
32 | Fsck canceled |
128 | Shared library error |
Key Use Cases
- Filesystem repair
- Error checking
- System maintenance
- Recovery operations
- Boot problems
Examples with Explanations
Example 1: Basic Check
fsck /dev/sdb1
Check specific device
Example 2: Force Check
fsck -f /dev/sdc1
Force check even if clean
Example 3: Auto-repair
fsck -y /dev/sdd1
Automatically fix errors
Common Usage Patterns
Check all:
fsck -A -V
Dry run:
fsck -N /dev/sdb1
Progress bar:
fsck -C /dev/sdc1
Security Considerations
- Root access
- Data integrity
- System stability
- Backup importance
- Mount status
Additional Resources
Best Practices
- Regular checks
- Unmount first
- Backup data
- Document errors
- Monitor logs
Error Types
- Inode errors
- Block errors
- Directory errors
- Superblock issues
- Journal problems
Troubleshooting
- Boot issues
- Mount failures
- Data corruption
- Performance problems
- System crashes