![]() |
VOOZH | about |
dosfsck stands for DOS File System Consistency Check and is part of the dosfstools package in Unix-like operating systems. This command diagnoses and repairs MS-DOS filesystems (FAT12, FAT16, FAT32). Before running dosfsck, it is crucial to unmount the filesystem to avoid data corruption.
dosfsck [options] deviceThe most basic usage of dosfsck simply requires specifying the device you want to check.
dosfsck [-aAflrtvVwy] [-d path -d ...] [-u path -u ...] /dev/sdX1'dosfsck' command can be used to correct some below the mentioned problems:
These filesystem problems can also be detected but are not fixed by dosfsck command if:
| Option | Description |
|---|---|
-a | Automatically repair the filesystem. |
-A | Toggle Atari variation of the MS-DOS filesystem. |
-b | Perform a readonly check on the boot sector. |
-d | Delete the specified file. |
-f | Salvage unused cluster chains to files. Unused clusters are typically added to free disk space. |
-l | List path names of files being processed. |
-n | No-operation mode; check is performed without making any changes. |
-p | Automatically repair filesystem errors (similar to -a). |
-r | Interactive mode; prompts user for decisions when there are multiple ways to fix an error. |
-t | Mark unreadable clusters as bad. |
-u | Try to undelete the specified file. |
-v | Verbose mode; shows more details about the repairs being made. |
-V | Perform a verification pass without making any changes. |
-w | Write changes to disk immediately after fixing errors. |
-y | Automatically answer 'yes' to all prompts (similar to -a) |
Understanding the exit codes returned by dosfsck helps you determine the result of the commandβs execution:
Let us look at some of the examples of dosfsck command to better understand the concept.
To automatically repair the filesystem on a FAT-formatted partition, use the -a option:
sudo dosfsck -a /dev/sdb1π Image
To perform a readonly check of the boot sector, use the -b option
sudo dosfsck -b /dev/sdb1π Image
You can list the path names of files being processed by 'dosfsck' using the '-l' option:
sudo dosfsck -l /dev/sdb1π Image
Verbose way of checking and repairing the filesystem non-interactively. The '-t' used to mark unreadable clusters as bad, this will make them unavailable for new files and directories.
sudo -v -a -t /dev/sdb1π Image
If you want to run 'dosfsck' in verification mode without making any changes to the filesystem, use the '-V' option:
sudo dosfsck -V /dev/sdb1π Image
The 'dosfsck' command is a versatile and essential tool for maintaining FAT-formatted filesystems on Unix-like operating systems. It offers both automatic and interactive options to diagnose and repair a wide range of filesystem issues. By following the above mentioned examples, you can confidently manage and repair MS-DOS filesystems using dosfsck.