Skip to content
Related Articles
Open in App
Not now

Related Articles

dosfsck command in Linux with Examples

Improve Article
Save Article
  • Last Updated : 01 May, 2019
Improve Article
Save Article

dosfsck stands for DOS File System Consistency Check. It is a component of dosfstools package in the Unix-like operating systems. In order to use dosfsck dosfstools package needs to be installed. dosfsck command diagnose MS-DOS file system for problems and attempts to repair them. Always unmount the file system before running dosfsck to avoid any courruption issues.


dosfsck [-aAflrtvVwy] [-d path -d ...] [-u path -u ...]  device

dosfsck command can be used to for correcting some below mentioned problems:

  • If FAT contains invalid cluster numbers then cluster is changed to EOF.
  • If file’s cluster chain contains a loop, then loop is broken.
  • Bad clusters are marked and removed from files or directories occupying them. This is a optional check.
  • Directories having large number of bad or corrupt entries, can be dropped.
  • Files . and .. are non-directories, can be dropped or renamed.
  • Directories . and .. in root directory. They are dropped.
  • Bad file names, can be renamed.
  • Duplicate directories can be renamed or dropped.
  • Directories with non-zero size field is set to zero.
  • If directory . does not point to parent directory then start pointer is adjusted.
  • If directory .. does not point to parent of parent directory then start pointer is adjusted.
  • If start cluster number of a file is invalid then that file is truncated.
  • File containing bad or free clusters is truncated.
  • If file’s cluster chain is longer than that indicated by size field then file is truncated.
  • If file’s cluster chain is shorter than that indicated by size fields then file is truncated.
  • If clusters are marked as used but not occupied by the file then they are marked as free.

These filesystem problems can also be detected but are not fixed by dosfsck command if:

  • Invalid parameters detected in boot sector.
  • . and .. entries not found in non-root directories.


  • -a : Automatically repair the file system.
  • -A : Toggle Atari variation of the MS-DOS filesystem.
  • -b : Make readonly boot sector check.
  • -d : Delete specified file.
  • -f : Salvage unused cluster chains to files. By default, unused clusters are added to the free disk space except in auto mode (-a).
  • -l : List the path names of files which are being processed.
  • -n : It is no-operation mode, check is performed non-interactively and changes are made to the filesystem.
  • -p : Similar to -a, for compatibility with other fsck.
  • -r : Check is performed Interactively. User is asked whenever there is more than one approach for fix.
  • -t : Mark unreadable clusters as bad.
  • -u : Try to undelete the specified file.
  • -v : Verbose mode. Provides additional details of repairs being made.
  • -V : Perform a verification pass.
  • -w : Write changes to disk as soon as they(errors) are fixed.
  • -y : Similar to -a for compatibility with other fsck tools.

Exit Codes for dosfsck:

0 : No recoverable errors were detected.
1 : Recoverable errors or internal inconsistency was detected.
2 : Usage or Syntax error.


  • Automatically repair the file system.
    sudo dosfsck -a /dev/sdb1

  • Make readonly boot sector check
    sudo dosfsck -b /dev/sdb1

  • List path names of files being processed.
    sudo dosfsck -l /dev/sdb1

  • 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

  • Perform a verification pass
    sudo -V /dev/sdb1

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!