Last Updated : 12 Jul, 2025
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.
Syntax:dosfsck [options] device
The most basic usage of dosfsck
simply requires specifying the device you want to check.
dosfsck [-aAflrtvVwy] [-d path -d ...] [-u path -u ...] /dev/sdX1Common Issues Resolved by 'dosfsck' Command
'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:
-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) Exit Codes for dosfsck
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.
1. Automatically repair the file system.To automatically repair the filesystem on a FAT-formatted partition, use the -a option:
sudo dosfsck -a /dev/sdb12. Readonly boot sector check
To perform a readonly check of the boot sector, use the -b option
sudo dosfsck -b /dev/sdb13. List path names of files being processed
You can list the path names of files being processed by 'dosfsck' using the '-l' option:
sudo dosfsck -l /dev/sdb14. Verbose Check and Repair with Marking Bad Clusters
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/sdb15. Perform a Verification Pass
If you want to run 'dosfsck' in verification mode without making any changes to the filesystem, use the '-V' option:
sudo dosfsck -V /dev/sdb1Conclusion
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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4