Q. What command I need to run to check file system consistency under UNIX or Linux like operating systems?
A. You need to run fsck [file system consistency check] command to check file system consistency and repair a Linux / UNIX file system. Microsoft Windows/DOS equivalent programs are scandisk and chkdsk.
Normally, the fsck program will try to run filesystems on different physical disk drives in parallel to reduce total amount time to check all of the filesystems. Also note that fsck is run automatically at boot time when the system detects that a file system is in an inconsistent state, indicating a non-graceful shutdown, such as a crash or power loss.
You must unmout file system before running fsck command. fsck should always be run in a single user mode.
How do I use fsck program?
Following is general sequence for running fsck:
Goto single user mode:
# init 1
Unmount file system (for example /dev/sdb1 under Linux or under FreeBSD use /dev/ad0s1f etc) :
# umount /dev/sdb1
Now run fsck command:
# fsck /dev/sdb1
Now mount filesystem
# mount -a
Go backto multiuser mode 2/3:
# init 2
How do I run fsck under UNIX using alternate superblock?
You can run fsck command using alternate superblock, enter:
# fsck -F ufs -o b=32 /dev/rdsk/c0t0d0s6
Use newfs -N /dev/rdsk/c0t0d0s6 command to find out location of superblock.
Recommended readings
- Our article – Repairing ReiserFS file system with reiserfsck
- Surviving a Linux Filesystem Failures – Repairing ext2/3 using superblock
- Repairing Linux ext2 or ext3 file system
🐧 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |