FAT
The File Allocation Table (FAT) filesystem was originally created for use with MS-DOS (and later pre-NT Microsoft Windows); currently a later revision of FAT (FAT32) is used for USB flash disks.[1] It has made its way over to Linux systems and has official support in the Linux kernel.
As of August 26th, 2019 Microsoft has published the exFAT filesystem specification[2] which means support for exFAT can be worked into the mainline Linux kernel. Kernel 5.4 includes initial staging code[3] for exFAT support.
Installation[edit | edit source]
Kernel[edit | edit source]
File systems ---> DOS/FAT/NT Filesystems ---> < > MSDOS fs support <*> VFAT (Windows-95) fs support (437) Default codepage for FAT (iso8859-1) Default iocharset for FAT [ ] Enable FAT UTF-8 option by default -*- Native language support ---> (iso8859-1) Default NLS Option <*> Codepage 437 (United States, Canada) <*> NLS ISO 8859-1 (Latin 1; Western European Languages) -*- NLS UTF-8
When planning on mounting FAT partitions, users may need to specify a codepage=
option with mount. In the example above the codepage for the United States and Canada is used, however other codepages can be enabled a necessary. Optionally, users can also set a default codepage for FAT in the kernel configuration. Be sure each codepage value which is to be used has been enabled in the kernel.
Using the
codepage
option via the mount will override the settings used in the kernel.Avoid setting Default iocharset for fat
to UTF-8; it is not recommended. Instead, pass the utf8=true
option when mounting FAT partitions (this requires CONFIG_NLS_UTF8 to be enabled in the kernel. For further information see man 8 mount or see the appropriate kernel documentation at /usr/src/linux/Documentation/filesystems/vfat.txt
Emerge[edit | edit source]
The sys-fs/dosfstools package is needed for FAT userspace utilities:
root #
emerge --ask sys-fs/dosfstools
Usage[edit | edit source]
It should be possible to mount FAT filesystems with the mount command. Resizing could be done using sys-fs/fatresize.
Removal[edit | edit source]
To schedule removal for the next depclean action:
root #
emerge --ask --depclean --verbose sys-fs/dosfstools
Troubleshooting[edit | edit source]
Slow File Transfer Speeds[edit | edit source]
If file transfer speeds are slow (eg. View using iotop), ensure the filesystem is mounted with the async
filesystem option. Edit /etc/fstab (or /etc/autofs/auto.misc when using autofs) system files as needed, likely removing the sync
mount option. By default, filesystems are mounted using the "async" mount option.
The filesystem
sync
mount option inhibits slower transfer speeds than the default async
mount option, and the sync
mount option may cause flash media life-cycle shortening! See man mount option sync
explanation.If file transfer speeds are still slow, try remounting the filesystem with the flush
mount option:
root #
mount -o remount,flush /path/to/mountpoint
Alternative Operating System Compatible Filesystems[edit | edit source]
Try UDF filesystem using UDFTools, requiring sys-fs/udftools and Linux kernel UDF filesystem driver. Recently code was added to mkudffs for a fix for creating a mock partition increasing compatability with Microsoft related operating systems. If using an older Linux kernel, ensure block size is set to 512 for increased compatability. Most options are now default for compatability, except for the required "--bootarea=mbr" creating the mock partition.
root #
mkudffs --bootarea=mbr --label=your_label /dev/device_file
Try Samsung's F2FS filesystem.
UTF-8/UTF-16 Character Hardware Bugs[edit | edit source]
Sometimes hardware firmware bugs will occur on embedded devices (eg. car radios) when reading their required formatted FAT/FAT32 filesystems containing UTF-8 characters. A workaround is to ensure initially mounting the FAT filesystem using (current default) mount options "codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro". For short filenames, "codepage=437" is IBM-PC characters or basically ASCII. For long filenames, "iocharset=iso8859-1" specifies ASCII. The option "shortname=mixed" is default, and can also try "shortname=win95" option. Of which, are all current defaults. Additionally to further remedy UTF-8/UTF-16 incompatible characters, use a loop with sed to replace all incompatible UTF-8/UTF-16 characters with an underscore or other ASCII character. (See my replace_chars.shscript.) For reference, I ran into this bug with one of Sony car radios, a MEX-GS610BT radio model would hard reset upon attempting to read a USB flash media/drive containing UTF-8/UTF-16 characters.
As mentioned previously, see /usr/src/linux/Documentation/filesystems/vfat.txt, the Linux Kernel VFat source code documenation, for further explanation on whether to use codepage, iocharset or utf8 mount options.
Unsorted Files and Folders[edit | edit source]
When writing files to the FAT/FAT32 filesystem, devices used for reading the filesystem may show the files and folders as unsorted. Commonly, we prefer seeing our files and folders sorted alphabetically. Install sys-fs/fatsort, and issue the following command:
root #
fatsort /dev/device_file
See also[edit | edit source]
- ext4 — an open source disk filesystem and most recent version of the extended series of filesystems. ext4 is the most popular Linux filesystem.
- btrfs — a copy-on-write (CoW) filesystem for Linux aimed at implementing advanced features while focusing on fault tolerance, repair, and easy administration.
- filesystem — a means to organize data expected to be retained after a program terminates by providing procedures to store, retrieve, and update data as well as manage the available space on the device(s) which contain it.
- mount — the attaching of an additional filesystem to the currently accessible filesystem of a computer.
- removable media — consists of any media that is easily removed from a system
- fstab — a configuration file that is used to configure how and where the main filesystems are to be mounted, especially at boot time.
External resources[edit | edit source]
- /usr/src/linux/Documentation/filesystems/vfat.txt - Documentation on the VFAT filesystem included with the Linux kernel sources.
- FAT filesystem and Linux - from Wikipedia
- FAT - from the Arch Linux wiki