This article is about File System Check and Check Disk and how to run them.
Linux, FreeBSD, and other UNIX-based systems
File System Check
A File System Check (fsck) is run automatically at boot time (when the operating system detects that a file system is in an inconsistent state), or periodically (to prevent small, undetected inconsistencies from becoming exacerbated).
There are multiple ways to check a file system. You can either run it to fix everything automatically, or you can run it to check if there is any problem with the file system. A fsck should always be run on an unmounted file system and should not be run on a file system that is working correctly. We recommended not to cancel or interrupt a fsck.
When you want to run a fsck, it is recommended to boot the server in a live environment as the file systems are not mounted, providing a better chance of recovery. Before you start, you must decide how you would run the fsck.
Examples:
Say yes to all repairs:
fsck –y /dev/sda1
Check if the file system needs repair by running:
fsck /dev/sda1
Bad superblock
You can also set up a new superblock.
Example:
- Check which superblock is being used by running:
fsck –v /dev/sda1 - Check which superblocks are available by running:
mke2fs -n /dev/sda1 - Select a new superblock and execute the following command:
fsck -b /dev/sda1 - Reboot the server.
For more information about fsck, please visit http://bit.ly/9XoAcG.
Windows
Check Disk
Checks the file system and file system metadata of a volume for logical and physical errors. If used without parameters, chkdsk displays only the status of the volume, and does not fix any errors. If used with the /f, /r, /x, or /b parameters, it fixes errors on the volume accordingly.
The following parameters are usually used to run on a File System that does not respond.
/f | Fixes errors on the disk. The disk must be locked. If chkdsk cannot lock the drive, a message appears that asks if you want to check the drive the next time you restart the computer. |
/r | Locates bad sectors and recovers readable information. The disk must be locked. /r includes the functionality of /f, with the additional analysis of physical disk errors. |
/x | Forces the volume to dismount first, if necessary. All open handles to the drive are invalidated. /x also includes the functionality of /f. |
/b | NTFS only: Clears the list of bad clusters on the volume and rescans all allocated and free clusters for errors. /b includes the functionality of /r. Use this parameter after imaging a volume to a new hard disk drive. |
For more information about chkdsk, please visit http://bit.ly/180j1n4.