mkfs.fat
Create a FAT filesystem
TLDR
Create a fat filesystem inside partition Y on device X
Create filesystem with a volume-name
Create filesystem with a volume-id
Use 5 instead of 2 file allocation tables
SYNOPSIS
mkfs.fat [-a] [-A] [-c] [-f sectors] [-F {12,16,32}] [-i id] [-I] [-l filename] [-m filename] [-n label] [-o offset] [-r root-entries] [-R reserved-sectors] [-s sectors-per-cluster] [-S sector-size] [-v] [-V label] device
PARAMETERS
-a
Check the device for bad blocks after creating the filesystem.
-A
Use Atari variation of the FAT filesystem. Implies -F 16 if no FAT type is specified.
-c
Check the device for bad blocks before creating the filesystem.
-f sectors
Specify number of sectors for FAT (12, 16, 32). Overrides the automatically calculated value.
-F {12,16,32}
Specify the FAT type (12, 16, or 32).
-i id
Set the volume ID (hexadecimal number).
-I
Create an image file instead of writing to a device.
-l filename
Read bad block list from filename.
-m filename
Copy initial contents from filename.
-n label
Set the volume label (up to 11 characters).
-o offset
Sector offset for the filesystem.
-r root-entries
Number of root directory entries for FAT12 and FAT16 filesystems.
-R reserved-sectors
Specify number of reserved sectors.
-s sectors-per-cluster
Specify sectors per cluster.
-S sector-size
Specify sector size (bytes).
-v
Verbose mode.
-V label
Set the volume label (alternative option).
device
The device or file to format.
DESCRIPTION
mkfs.fat, formerly known as mkdosfs, creates a FAT (File Allocation Table) filesystem on a specified device or file. It is a crucial tool for preparing storage media, such as USB drives or partitions, for compatibility with a wide range of operating systems, including DOS, Windows, and embedded systems. The command allows you to specify the FAT type (12, 16, or 32), volume label, and other filesystem parameters. It's important to use this command with caution as it will overwrite any existing data on the target device.
mkfs.fat formats a device to be compatible with BIOS bootloaders for DOS, and modern UEFI system. It's typically found and used in embedded devices where mass storage is based around the FAT standard.
CAVEATS
Using mkfs.fat will erase all existing data on the specified device. Ensure you have selected the correct device before running the command.
EXIT STATUS
mkfs.fat returns 0 on success, and non-zero on failure.
DEFAULT BEHAVIOR
If no FAT type is specified, mkfs.fat automatically selects the appropriate type based on the device size. Generally, smaller devices default to FAT12, medium-sized devices to FAT16, and larger devices to FAT32.
HISTORY
The command originated as mkdosfs, specifically designed for creating FAT filesystems compatible with DOS. Over time, it evolved into mkfs.fat to better reflect its support for various FAT versions and its broader applicability beyond DOS-specific systems. It has been consistently maintained and updated to address compatibility issues and incorporate new features related to FAT filesystem management.