FSCK.FAT(8)
๐ FSCK.FAT(8) ๐
โจ NAME โจ
okay so the tool here is fsck.fat, and its whole job is to check and repair MS-DOS FAT filesystems ๐
๐ SYNOPSIS ๐
fsck.fat [OPTIONS] DEVICE
๐ธ DESCRIPTION ๐ธ
fsck.fat verifies that MS-DOS filesystems are consistent, and if you ask nicely (with the right flags) it'll try to fix them too ๐ซถ
Here are the filesystem problems it can fix, in this exact order:
- FAT contains invalid cluster numbers. The cluster gets changed to EOF.
- A file's cluster chain has a loop. The loop gets broken.
- Bad clusters (read errors). They're marked bad and removed from whatever files own them. This check is optional ๐
- Directories with a large number of bad entries (probably corrupt). The directory can be deleted. bye bye ๐ญ
- Files
.and..are non-directories. They can be deleted or renamed. - Directories
.and..in the root directory. They get deleted. - Bad filenames. They can be renamed.
- Duplicate directory entries. They can be deleted or renamed.
- Directories with a non-zero size field. The size gets set to zero.
- Directory
.doesn't point to its parent directory. The start pointer is adjusted. - Directory
..doesn't point to the parent of its parent directory. The start pointer is adjusted. .and..aren't the first two entries in a non-root directory. The entries get created, and occupied slots get moved out of the way if needed.- A file's start cluster number is invalid. The file gets truncated.
- A file contains bad or free clusters. The file gets truncated.
- A file's cluster chain is longer than its size fields say. The file gets truncated.
- Two or more files share the same cluster(s). All but one of them get truncated. If the file being truncated is a directory file that was already read, the filesystem check restarts after truncation ๐
- A file's cluster chain is shorter than its size fields say. The file gets truncated.
- The volume label in the root directory, or the label in the boot sector, is invalid. Invalid labels get removed.
- The volume label in the root directory and the label in the boot sector are different. The volume label from the root directory gets copied to the boot sector.
- Clusters are marked as used but aren't owned by any file. They get marked as free.
Additionally, there's one problem it detects but does not repair:
- Invalid parameters in the boot sector
โ ๏ธ Whenfsck.fatchecks a filesystem, it stashes all of its changes in memory and only performs them after every check is done. You can turn this off with the-woption.
Two different variants of the FAT filesystem are supported. The standard one is FAT12, FAT16 and FAT32 as defined by Microsoft, and it's what you'll find on hard disks and removable media like USB sticks and SD cards ๐พ The other is the legacy Atari variant used on Atari ST.
The Atari format has some small differences. A few boot sector fields get interpreted slightly differently, and the special FAT entries for end-of-file and bad cluster can be different too. Under MS-DOS, 0xfff8 is used for EOF, and Atari uses 0xffff by default, but both systems recognize every value from 0xfff8โ0xffff as end-of-file. MS-DOS only uses 0xfff7 for bad clusters, whereas on Atari the values 0xfff0โ0xfff7 are for this purpose (though the standard value is still 0xfff7).
๐ฆ OPTIONS ๐ฆ
-aโ Auto-repair the filesystem with zero user intervention needed ๐ค Whenever there's more than one way to fix a problem, the least destructive approach gets picked.-Aโ Switches to the Atari variant of the FAT filesystem if it isn't already active, otherwise switches to the standard one. This is selected by default whenmkfs.fatruns on 68k Atari Linux.-bโ Does a read-only boot sector check.-c PAGEโ Uses DOS codepagePAGEto decode short file names. By default, codepage 850 is used.-d PATHโ Deletes the specified file. If more than one file has that name, the first one gets deleted. You can give this option more than once ๐๏ธ-fโ Salvages unused cluster chains into files. By default, unused clusters get added back to the free disk space, except in auto mode (-a).-F NUMโ Uses FAT tableNUMfor filesystem access. By default the value is0, and then the first uncorrupted FAT table gets chosen. "Uncorrupted" means the FAT table has a valid first cluster. If you keep the default0and every FAT table is corrupted,fsck.fatgives up and doesn't try to repair the FAT filesystem ๐ต If you specify a non-zeroNUM,fsck.fatuses FAT tableNUMto repair the filesystem, and if that table has a corrupted first cluster,fsck.fatwill repair it. In any case, if the FAT filesystem has more FAT tables, the repaired content of the chosen FAT table gets copied to the other FAT tables. To repair a corrupted first cluster, you have to callfsck.fatwith a non-zeroNUMvalue.-lโ Lists the path names of the files being processed.-nโ No-operation mode! It checks for errors non-interactively, but doesn't write anything to the filesystem ๐-pโ Same as-a, just for compatibility with other*fscktools.-rโ Interactively repairs the filesystem. Whenever there's more than one approach to fix an inconsistency, you get asked for advice. This is the default mode, and the option is only kept around for backwards compatibility.-Sโ Treats short (8.3) file names with spaces in the middle as invalid, the way previous versions of this program did ๐ โโ๏ธ Here's the tea: the FAT spec doesn't forbid these names, and Microsoft's own file system checking tools never flagged them as errors. But plenty of DOS programs can't handle files with names like that. Using this option can make those files accessible to those programs.
Short file names that start with a space are considered invalid no matter how this option is set.
Previous versions of this program made a special exception and treated EA DATA. SF and WP ROOT. SF as valid short names. Using this option does not keep that exception.
-tโ Marks unreadable clusters as bad.-u PATHโ Tries to undelete the specified file.fsck.fatattempts to allocate a chain of contiguous unallocated clusters starting from the start cluster of the undeleted file. You can give this option more than once ๐ช-Uโ Treats lowercase volume and boot labels as invalid, and only allows uppercase characters. The FAT spec forbids lowercase labels, but Linux tools use them all the time. MS-DOS and Windows have no trouble reading them, so by default, volume and boot labels with lowercase characters are allowed ๐ซถ-vโ Verbose mode. Generates slightly more output ๐ฃ-Vโ Performs a verification pass. The filesystem check gets repeated after the first run. The second pass should never report any fixable errors. It can take a lot longer than the first pass, because the first pass may have generated a long list of modifications that has to be scanned on every disk read ๐ข--variant TYPEโ Creates a filesystem of variantTYPE. The acceptable values arestandardandatari(in any combination of upper and lower case). Check the DESCRIPTION section above for the differences.-wโ Writes changes to disk immediately โก-yโ Same as-a(auto-repair the filesystem), just for compatibility with other fsck tools.--helpโ Displays a help message describing usage and options, then exits ๐โโ๏ธ
๐ EXIT STATUS ๐
0โ No recoverable errors were detected. Slay โจ1โ Recoverable errors were detected, orfsck.fatran into an internal inconsistency ๐ฌ2โ Usage error.fsck.fatdidn't access the filesystem.
๐ FILES ๐
fsck0000.rec, fsck0001.rec, ...โ When recovering from a corrupted filesystem,fsck.fatdumps the recovered data into files namedfsckNNNN.recin the top level directory of the filesystem.
๐ BUGS ๐
- It doesn't remove entirely empty directories. ๐ญ
- It should give more diagnostic messages.
- Undeleting files should use a more sophisticated algorithm.
๐ SEE ALSO ๐
๐ HOMEPAGE ๐
The home for the dosfstools project is its GitHub project page.
๐ AUTHORS ๐
dosfstools were written by Werner Almesberger, Roman Hodek, and others. The current maintainers are Andreas Bombe and Pali Rohรกr ๐ซถ
Bestie, that's the whole FSCK.FAT(8) page, served with extra sparkle ๐ dosfstools 4.2, last updated 2021-01-31 ๐ Stay iconic and keep your FAT tables healthy ๐ง๐ธ
๐ฆ where this page comes from
- alpine 3.22: dosfstools-doc 4.2-r2 ยท GPL-3.0-or-later
- alpine 3.23: dosfstools-doc 4.2-r2 ยท GPL-3.0-or-later
- alpine 3.24: dosfstools-doc 4.2-r2 ยท GPL-3.0-or-later
- arch rolling: dosfstools 4.2-5 ยท GPL-3.0-or-later
- centos-stream 10: dosfstools 4.2-12.el10 ยท GPL-3.0-or-later
- centos-stream 9: dosfstools 4.2-3.el9 ยท GPLv3+
- debian bookworm: dosfstools 4.2-1 ยท GPL-3.0-or-later
- debian trixie: dosfstools 4.2-1.2 ยท GPL-3.0-or-later
- fedora 43: dosfstools 4.2-16.fc43 ยท GPL-3.0-or-later
- fedora 44: dosfstools 4.2-18.fc44 ยท GPL-3.0-or-later
- nixpkgs unstable: dosfstools 4.2
- opensuse-leap 16.0: dosfstools 4.2-160000.2.2 ยท GPL-3.0-or-later
- opensuse-leap 16.0: dosfstools 4.2-160000.2.2 ยท GPL-3.0-or-later
- opensuse-leap 16.0: dosfstools 4.2-160000.2.2 ยท GPL-3.0-or-later
- opensuse-leap 16.0: dosfstools 4.2-160000.2.2 ยท GPL-3.0-or-later
- ubuntu jammy: dosfstools 4.2-1build3 ยท GPL-3.0-or-later
- ubuntu noble: dosfstools 4.2-1.1build1 ยท GPL-3.0-or-later
- ubuntu questing: dosfstools 4.2-1.2 ยท GPL-3.0-or-later
- ubuntu resolute: dosfstools 4.2-1.2build1 ยท GPL-3.0-or-later
- ubuntu stonking: dosfstools 4.2-1.2build1 ยท GPL-3.0-or-later
- Copyright (C) 2006-2014 Daniel Baumann <daniel@debian.org>
- Copyright (C) 2018-2021 Pali Rohรกr <pali.rohar@gmail.com>
- ๐ girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms