# fsck.msdos(8) - man - phpman

[FSCK.FAT(8)](https://www.chedong.com/phpMan.php/man/FSCK.FAT/8/markdown)                            System Manager's Manual                           [FSCK.FAT(8)](https://www.chedong.com/phpMan.php/man/FSCK.FAT/8/markdown)



## NAME
       fsck.fat - check and repair MS-DOS FAT filesystems

## SYNOPSIS
       **fsck.fat** [_OPTIONS_] _DEVICE_

## DESCRIPTION
       **fsck.fat** verifies the consistency of MS-DOS filesystems and optionally tries to repair them.

       The following filesystem problems can be corrected (in this order):

       •   FAT contains invalid cluster numbers.  Cluster is changed to EOF.

       •   File's cluster chain contains a loop.  The loop is broken.

       •   Bad  clusters (read errors).  The clusters are marked bad and they are removed from files
           owning them.  This check is optional.

       •   Directories with a large number of bad entries (probably corrupt).  The directory can  be
           deleted.

       •   Files . and .. are non-directories.  They can be deleted or renamed.

       •   Directories . and .. in root directory.  They are deleted.

       •   Bad filenames.  They can be renamed.

       •   Duplicate directory entries.  They can be deleted or renamed.

       •   Directories with non-zero size field.  Size is set to zero.

       •   Directory . does not point to parent directory.  The start pointer is adjusted.

       •   Directory  ..  does  not  point  to parent of parent directory.  The start pointer is ad‐
           justed.

       •   . and .. are not the two first entries in a non-root directory.  The entries are created,
           moving occupied slots if necessary.

       •   Start cluster number of a file is invalid.  The file is truncated.

       •   File contains bad or free clusters.  The file is truncated.

       •   File's cluster chain is longer than indicated by the size fields.  The file is truncated.

       •   Two or more files share the same cluster(s).  All but one of the files are truncated.  If
           the file being truncated is a directory file that has already been read,  the  filesystem
           check is restarted after truncation.

       •   File's  cluster  chain  is  shorter than indicated by the size fields.  The file is trun‐
           cated.

       •   Volume label in root directory or label in boot sector is invalid.   Invalid  labels  are
           removed.

       •   Volume label in root directory and label in boot sector are different.  Volume label from
           root directory is copied to boot sector.

       •   Clusters are marked as used but are not owned by a file.  They are marked as free.

       Additionally, the following problems are detected, but not repaired:

       •   Invalid parameters in boot sector

       When **fsck.fat** checks a filesystem, it accumulates all changes in  memory  and  performs  them
       only after all checks are complete.  This can be disabled with the **-w** option.

       Two different variants of the FAT filesystem are supported.  Standard is the FAT12, FAT16 and
       FAT32 filesystems as defined by Microsoft and widely used on hard disks and  removable  media
       like USB sticks and SD cards.  The other is the legacy Atari variant used on Atari ST.

       There  are  some  minor  differences in Atari format: Some boot sector fields are interpreted
       slightly different, and the special FAT entries for end-of-file and bad cluster can  be  dif‐
       ferent.   Under  MS-DOS  0xfff8 is used for EOF and Atari employs 0xffff by default, but both
       systems recognize all values from 0xfff8–0xffff as end-of-file.  MS-DOS uses only 0xfff7  for
       bad  clusters,  where  on  Atari  values 0xfff0–0xfff7 are for this purpose (but the standard
       value is still 0xfff7).

## OPTIONS
### -a
           is more than one method to solve a problem, the least destructive approach is used.

### -A
           erwise select standard FAT filesystem.  This is selected by default if **mkfs.fat** is run on
           68k Atari Linux.

### -b

### -c
           Use DOS codepage _PAGE_ to decode short file names.  By default codepage 850 is used.

### -d
           Delete  the specified file.  If more than one file with that name exist, the first one is
           deleted.  This option can be given more than once.

### -f
           free disk space except in auto mode (**-a**).

### -F
           Specify  FAT table _NUM_ for filesystem access.  By default value _0_ is assumed and then the
           first uncorrupted FAT table is chosen.  Uncorrupted means that FAT table has valid  first
           cluster.  If default value _0_ is used and all FAT tables are corrupted then **fsck.fat** gives
           up and does not try to repair FAT filesystem.  If non-zero _NUM_ value  is  specified  then
           **fsck.fat** uses FAT table _NUM_ for repairing FAT filesystem.  If FAT table _NUM_ has corrupted
           first cluster then **fsck.fat** will repair it.  In any case, if FAT filesystem has more  FAT
           tables  then  repaired content of chosen FAT table is copied to other FAT tables.  To re‐
           pair corrupted first cluster it is required to call **fsck.fat** with non-zero _NUM_ value.

### -l

### -n
           filesystem.

### -p -a

### -r
           than one approach to fix an inconsistency.  This is the default mode and  the  option  is
           only retained for backwards compatibility.

### -S
           versions of this program did.  While such file names are not forbidden by the FAT  speci‐
           fication,  and were never treated as errors by Microsoft file system checking tools, many
           DOS programs are unable to handle files with such names.  Using this option can make them
           accessible to these programs.

           Short  file  names which _start_ with a space are considered invalid regardless of this op‐
           tion's setting.

           Previous versions of this program exceptionally treated _EA_ _DATA._ _SF_ and _WP_  _ROOT._  _SF_  as
           valid short names; using this option does not preserve that exception.

### -t

### -u
           Try to undelete the specified file.  **fsck.fat** tries to allocate a chain of contiguous un‐
           allocated clusters beginning with the start cluster of the undeleted file.   This  option
           can be given more than once.

### -U
           Such labels are forbidden by the FAT specification, but they are  widely  used  by  Linux
           tools.  Moreover MS-DOS and Windows systems do not have problems to read them.  Therefore
           volume and boot labels with lowercase characters are by default permitted.

### -v

### -V
           second pass should never report any fixable errors.  It may take considerably longer than
           the first pass, because the first pass may have generated long list of modifications that
           have to be scanned for each disk read.

       **--variant** _TYPE_
           Create  a  filesystem  of variant _TYPE_.  Acceptable values are _standard_ and _atari_ (in any
           combination of upper/lower case).  See above under DESCRIPTION for the differences.

### -w

### -y -a

### --help
           Display help message describing usage and options then exit.

## EXIT STATUS
       0   No recoverable errors have been detected.

       1   Recoverable errors have been detected or **fsck.fat** has discovered  an  internal  inconsis‐
           tency.

       2   Usage error.  **fsck.fat** did not access the filesystem.

## FILES
       _fsck0000.rec_, _fsck0001.rec_, ...
           When  recovering  from  a  corrupted filesystem, **fsck.fat** dumps recovered data into files
           named _fsckNNNN.rec_ in the top level directory of the filesystem.

## BUGS
       •   Does not remove entirely empty directories.

       •   Should give more diagnostic messages.

       •   Undeleting files should use a more sophisticated algorithm.

## SEE ALSO
       [**fatlabel**(8)](https://www.chedong.com/phpMan.php/man/fatlabel/8/markdown), [**mkfs.fat**(8)](https://www.chedong.com/phpMan.php/man/mkfs.fat/8/markdown)

## HOMEPAGE
       The    home    for    the    **dosfstools**    project    is    its    GitHub    project     page
       ⟨<https://github.com/dosfstools/dosfstools>⟩.

## AUTHORS
       **dosfstools**  were  written  by  Werner  Almesberger ⟨<werner.almesberger@lrc.di.epfl.ch>⟩, Roman
       Hodek ⟨<Roman.Hodek@informatik.uni-erlangen.de>⟩, and others.  Current maintainers are  Andreas
       Bombe ⟨<aeb@debian.org>⟩ and Pali Rohár ⟨<pali.rohar@gmail.com>⟩.



dosfstools 4.2                               2021-01-31                                  [FSCK.FAT(8)](https://www.chedong.com/phpMan.php/man/FSCK.FAT/8/markdown)
