LinuxCommandLibrary

fsck.fat

Check and repair FAT filesystems

SYNOPSIS

fsck.fat [-v|-w|-r|-l|-t|-V] [-a|-p] [-d path] [-c n] [-u drive-number] device

PARAMETERS

-v
    Verbose mode. Provides more detailed output during the check and repair process.

-w
    Write-enable. Allows fsck.fat to make changes to the filesystem. Required for repair operations.

-r
    Interactive repair mode. Prompts the user for confirmation before each repair action.

-l
    List pathnames of all files. Useful for detecting long filename issues.

-t
    Test mode. Simulates the repair process without writing any changes to the filesystem.

-V
    Perform a verification of the cluster chain, used along with '-w' flag.

-a
    Automatically repair the filesystem without prompting (dangerous).

-p
    Same as -a, but only performs repairs that are deemed 'safe'.

-d path
    Delete the specified directory entry.

-c n
    Perform n passes of consistency check.

-u drive-number
    Sets the BIOS drive number (used for FAT12/16).

device
    The device file representing the FAT filesystem (e.g., /dev/sdb1).

DESCRIPTION

fsck.fat is a utility for checking and repairing MS-DOS FAT filesystems (FAT12, FAT16, and FAT32) on Linux and other Unix-like operating systems.
It examines the filesystem for inconsistencies, such as lost clusters, cross-linked files, and directory structure errors.
Upon detecting errors, fsck.fat attempts to repair them, often prompting the user for confirmation before making any changes.
It is a crucial tool for maintaining the integrity of FAT filesystems, especially on removable media like USB drives and SD cards. Running it without specifying any options will perform a read-only check and report the filesystem health.
The tool is safe, but user should perform backup operation before repair.

CAVEATS

Running fsck.fat with the '-a' option can be risky as it automatically attempts to fix any errors it finds without user confirmation. Always back up important data before using fsck.fat, especially with write-enabled options. It is not suitable for other filesystem types like ext4 or XFS. Damaged metadata can lead to data loss. Using -a or -p doesn't guarantee the complete and correct repair of all errors.

EXIT STATUS

fsck.fat returns an exit code indicating the success or failure of the operation:
0: No errors detected.
1: Errors detected and repaired.
2: Usage error.
4: System error (e.g., out of memory).
8: Operation interrupted by the user.
16: Device write error.

LONG FILENAME SUPPORT

fsck.fat can detect and sometimes repair errors related to long filenames (LFNs) in FAT filesystems, especially when LFN entries are corrupted or out of sync. The '-l' option can be used to display all file names and assist in identifying potentially problematic entries.

HISTORY

fsck.fat is derived from the dosfsck utility. The origin of dosfsck predates Linux itself, with its roots in tools designed to manage MS-DOS filesystems. Its development has been ongoing to adapt to changes in FAT standards, handle larger drives, and integrate into modern operating system environments. It's evolved to be part of the dosfstools package, ensuring its continued availability and support on Linux distributions. This tool has been used for a long time because of the popularity and compatibility of FAT format with different systems.

SEE ALSO

mkdosfs(8), dosfslabel(8)

Copied to clipboard