MKFS.FAT(8)
๐ MKFS.FAT(8) ๐
System Manager's Manual, the official Unix manual for this one ๐
โจ NAME โจ
mkfs.fat - create an MS-DOS FAT filesystem ๐
โจ SYNOPSIS โจ
mkfs.fat [OPTIONS] DEVICE [BLOCK-COUNT]
โจ DESCRIPTION โจ
okay so mkfs.fat is how you make a FAT filesystem ๐ง on a device, or inside an image file. DEVICE is the special file for the device (like /dev/sdXX) or the image file. The image file doesn't have to exist yet if you pass -C ๐ฆ
BLOCK-COUNT is the number of blocks on the device, and a block is always 1024 bytes, no matter the sector size or cluster size ๐คฏ So BLOCK-COUNT is the size of the filesystem in KiB, NOT in sectors (unlike every other mkfs.fat option, bestie ๐). If you leave it out, mkfs.fat picks a size that fills all the available space. โจ
There are two flavours of FAT filesystem ๐ Standard is FAT12, FAT16 and FAT32, the ones Microsoft defined and that everyone uses on hard disks and removable stuff like USB sticks and SD cards ๐ The other one is the legacy Atari variant, used on Atari ST machines ๐พ
In Atari mode, unless you tell it otherwise, mkfs.fat always uses 2 sectors per cluster, because GEMDOS does NOT like other values ๐ It also obeys the max number of sectors GEMDOS can handle. Bigger filesystems get handled by raising the logical sector size. It generates an Atari-compatible serial number for the filesystem, and only uses a 12 bit FAT for the usual floppy sizes (720k, 1.2M, 1.44M, 2.88M). Everything else gets a 16 bit FAT. You can override that with -F. Some PC-specific boot sector fields don't get written, and a boot message (-m) gets ignored ๐ฅบ
โจ OPTIONS โจ
-aโ By default, for any filesystem that isn't tiny,mkfs.fataligns all the data structures to the cluster size, so that as long as the partition is aligned, everything in the filesystem is too ๐ซถ This flag turns alignment OFF. You get a handful of extra clusters back, but you pay with a big performance hit on RAIDs, flash media, or large-sector hard disks ๐ญ-Aโ Flips between the Atari variant and the standard FAT filesystem. If Atari is already on, it selects standard, and vice versa. It's picked by default when you runmkfs.faton 68k Atari Linux ๐-b SECTOR-OF-BACKUPโ Picks where the backup boot sector for FAT32 lives. It depends on the number of reserved sectors, but it's usually sector 6 ๐ If there's free space after the backup boot sector, the backup of the FAT32 info sector goes right after it, usually at sector 7. The backup has to fall inside the reserved sectors range. A value of0totally disables making the backup boot and info FAT32 sectors.-cโ Checks the device for bad blocks before it makes the filesystem ๐-Cโ Creates the file you gave asDEVICEand writes the new filesystem into it. This is perfect if you want a filesystem in a file instead of on a real device, and it saves you from usingddbeforehand to make a file of the right size ๐ฐ With this flag,BLOCK-COUNTis required, because otherwise there's no way to know how big you want it. The file is sparse, which means it only really stores the metadata areas (boot sector, FATs, and root directory). The data parts aren't stored on disk, but the file still ends up the correct size ๐ง You can copy it onto a floppy or another device later, or mount it through a loop device.-D DRIVE-NUMBERโ Sets the BIOS drive number that gets stored in the FAT boot sector. For hard disks and removable media it's usually0x80โ0xFF(0x80is the first hard disk C:,0x81is the second hard disk D:, and so on). For floppy devices, or partitions used for floppy emulation, it's0x00โ0x7F(0x00is the first floppy A:,0x01is the second floppy B:) ๐พ-f NUMBER-OF-FATSโ Sets how many file allocation tables the filesystem has. The default is2โจ-F FAT-SIZEโ Sets the type of file allocation table (12, 16 or 32 bit). If you don't specify it,mkfs.fatautomatically picks whichever of 12, 16 and 32 bit fits the filesystem size best ๐ง-g HEADS/SECTORS-PER-TRACKโ Gives theHEADSandSECTORS-PER-TRACKnumbers that describe the disk geometry ofDEVICE. Both get stored in the FAT boot sector.SECTORS-PER-TRACKis also used to align the total count of FAT sectors ๐ By default the geometry is read fromDEVICEitself. If that's not available, it falls back to LBA-Assist Translation plus a translation table from the SD Card Part 2 File System Specification, based on the total number of disk sectors.-h NUMBER-OF-HIDDEN-SECTORSโ Sets the number of so-called hidden sectors, stored in the FAT boot sector. This number is the starting sector of the partition holding the filesystem ๐ซฃ Usually it's an offset (in sectors) from the start of the disk. But for MBR logical volumes inside an extended partition of type0x05(a non-LBA extended partition), a quirk in MS-DOS's FAT means it has to be relative to that partition's immediate containing Extended Boot Record. Boot code and other software that handles FAT volumes may also rely on this field being correct, though most modern FAT implementations ignore it. By default, ifDEVICEis a partition block device,mkfs.fatuses the partition offset relative to the disk start. Otherwise it assumes zero. Use this option to override that ๐ โโ๏ธ-i VOLUME-IDโ Sets the volume ID of the new filesystem.VOLUME-IDis a 32-bit hexadecimal number (for example,2e24ec82) ๐ข The default is a number based on the filesystem creation time.-Iโ Ignores and disables the safety checks. By defaultmkfs.fatrefuses to make a filesystem on a device that has partitions or virtual mappings, and it'll complain and tell you it won't work ๐ซ This is different for MO disks, since you don't always need partitions on those. The filesystem can go straight onto the whole disk, which other OSes call the "superfloppy" format. This switch forcesmkfs.fatto work anyway ๐ช-l FILENAMEโ Reads the bad blocks list fromFILENAME๐-m MESSAGE-FILEโ Sets the message you get when you try to boot this filesystem without a properly installed operating system ๐ The message file can't be bigger than 418 bytes once line feeds are converted to carriage return-line feed pairs and tabs are expanded. If the filename is a hyphen (-), the text is read from standard input.-M FAT-MEDIA-TYPEโ Sets the media type stored in the FAT boot sector. It's usually0xF8for hard disks, and0xF0or a value from0xF9to0xFFfor floppies or partitions used for floppy emulation ๐ฅฏ--mbr[=y|yes|n|no|a|auto]โ Fills in a (fake) MBR table with a disk signature and one partition that starts at sector 0 (including the MBR itself) and spans the whole disk device. This is only needed for non-removable disks used on Microsoft Windows systems, and only when you're formatting a whole unpartitioned disk ๐ช The disk signature and partition table overlap with the end of the first FAT sector (where the boot code lives), so it doesn't use any extra space. The default isautomode, which only puts an MBR table on non-removable disks when formatting a whole unpartitioned disk โจ-n VOLUME-NAMEโ Sets the volume name (label) of the filesystem. It can be up to 11 characters long ๐ท๏ธ An empty string, a string made only of whitespace, or the string"NO NAME"asVOLUME-NAMEdoes the same thing as not using-nat all. The default is no label.--codepage=PAGEโ Uses DOS codepagePAGEto encode the label. By default codepage850is used ๐-r ROOT-DIR-ENTRIESโ Picks the minimum number of entries in the root directory. The default is112or224for floppies and512for hard disks. This is the MINIMUM, somkfs.fatmight bump it up because of structure alignment. See also-a๐-R NUMBER-OF-RESERVED-SECTORSโ Picks the minimum number of reserved sectors. With the FAT32 format you need at least 2 reserved sectors, and the default is32. Otherwise the default is1(just the boot sector). Like-r, this is a minimum, somkfs.fatmay increase it for alignment. See also-a๐งธ-s SECTORS-PER-CLUSTERโ Sets the number of disk sectors per cluster. It has to be a power of 2, so1,2,4,8, ... up to128๐ข-S LOGICAL-SECTOR-SIZEโ Sets the number of bytes per logical sector. It has to be a power of 2 and at least512:512,1024,2048,4096,8192,16384, or32768. Heads up: values bigger than4096don't conform to the FAT filesystem spec and might not work everywhere ๐จ-vโ Verbose mode, so you get all the details as it goes ๐ฃ--offset SECTORโ Writes the filesystem starting at a specific sector inside the device file. This is handy for making a filesystem in a partitioned disk image WITHOUT needing to set up a loop device ๐งโโ๏ธ--variant TYPEโ Creates a filesystem of variantTYPE. The acceptable values arestandardandatari(any upper/lower case combo works). Check DESCRIPTION above for the differences ๐--helpโ Shows the option summary and exits ๐--invariantโ Uses constants in place of the stuff that's normally random or time based, like the volume ID and creation time. Runningmkfs.fatmultiple times on the same device gives identical results with this flag. Its main purpose is testingmkfs.fatitself ๐งช
โจ BUGS โจ
โ ๏ธmkfs.fatcan NOT create boot-able filesystems. It's not as easy as it sounds at first, for various reasons, and it's been discussed a LOT already.mkfs.fatsimply will not support it ;)
โจ SEE ALSO โจ
fatlabel(8), fsck.fat(8) ๐ซถ
โจ HOMEPAGE โจ
The home for the dosfstools project is its GitHub project page ๐ธ
โจ AUTHORS โจ
dosfstools were written by Werner Almesberger, Roman Hodek, and others ๐ Current maintainers are Andreas Bombe and Pali Rohรกr ๐ซถ
dosfstools 4.2, dated 2021-01-31, that's your sign-off bestie, you're officially a FAT filesystem expert now ๐๐ฆโจ
๐ฆ 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) 2016 Andreas Bombe <aeb@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