6
December
2022
exFAT file system for portable storage devices
16:06

exFAT file system for portable storage devices

6 December 2022 16:06

Why is exFAT better than NTFS?

For work, the organization purchased an SSD portable hard drive and a housing for HDD 2.5 to store the video archive. Before using the disk, I created an msdos partition table on it and formatted the partition into the NTFS file system. After a while, when connecting a USB cable, it stopped opening in Windows 10 and 8.1 - “Access denied”.

I copied its contents in Linux to a larger internal HDD. I formatted the SSD this time to exFAT.
Now I will always use exFAT for USB flash drives and portable HDDs!

The main advantages of exFAT over NTFS are listed below:

1) exFAT, like NTFS, allows you to save files larger than 4GB.

2) Linux exFAT support is built into kernel 5.4 or later. While NTFS support is implemented through the optional package "ntfs-3g".

3) Using exFAT reduces the load on the processor and disk controller when copying information and increases performance.

4) There are no problems with user and group rights - like in any FAT, there are none. Therefore, problems with the inability to read or write to the media will not arise.

5) Many USB flash drives come pre-formatted in exFAT. But exFAT can also be used for backup disks to which archives, database copies, or video files are copied.

6) exFAT is one of the most compatible file systems with portable devices (cell phones, mp3 players) as well as with TV and stationary DVD players. ExFAT support was implemented for the first time in Window XP (update KB955704), Windows 7, etc., in Linux from kernel 5.4 and higher.

7) exFAT only supports long file names.

8) The maximum number of files in a directory is actually limited by the number of clusters.

9) More efficient recording of long files without fragmentation. In exFAT, one bit in the directory entry indicates that the file is contiguous (not fragmented), telling the exFAT driver to ignore FAT." While NTFS needs to constantly access the block table. This improves the speed of exFAT when copying files.

10) There is a free space map, which also makes it easier and faster to write large files.

11)The main advantage of exFAT: The exFAT file system is recognized by all Microsoft operating systems, which allows transfer data between Linux and **Windows. Also, exFAT understands the operating system for smartphones and tablets -Android 9.0 and above, and also iOS** for Apple Mac (added 02/06/2025).

Optimal exFAT cluster size. Reserving space at the beginning of the disk

When formatting a large disk, you can specify a cluster size significantly higher than the standard NTFS 4 kB. The maximum size is 32 MB. For a 256MB–32GB disk, 32 KB clusters are optimal.

Formatting a partition in Windows into exFAT format with a cluster size of 32 kB:

diskpart
select disk 0
list partition
select partition 1
format fs=exFAT unit=32k quick

When formatting a disk from Linux to exFAT format, you can specify two parameter - boundary "-b" and cluster size "-c".
The lower border is needed for the so-called “alignment” of the section. This increases the speed of copying information.

The alignment argument is specified in bytes or can be specified with the suffix m/M for megabytes or the suffix k/K for kibibytes and must be a power of two. Some media, such as SD cards, require this setting for optimal performance and longevity of the media.

mkfs.exfat /dev/sdd1 -b 64k -c 32k -L "Cruiser 8Gb" 

where:
/dev/sdd1 - replace the volume name with the real name (can be found with the lsblk command).
-b - "boundary" parameter to allocate free space at the beginning of the disk to improve reliability and performance.
-c - cluster size.
-L "label name" - a symbolic disk label, where the text label name is up to 11 characters long inclusive (spaces are allowed).

For flash drives and microSD memory cards that do not have a volume (for example, lsblk outputs /dev/sdd).

sudo mkfs.exfat /dev/sdd -b 64k -c 32k

where:
/dev/sdd is the name of the disk that the lsblk command displayed for the memory card.

The values ​​-b and -c recommended by the USB Flash Manufacturers Association for disks of different sizes:

USB flash drive capacity, GB Options -b and -c
1-2 -b 64k -c 32k
2-32 -b 4M -c 32k
32-128 -b 16M -c 128k
128-512 -b 32M -c 256k
512-2048 -b 64M -c 512k

For example, for a 16 GB flash drive, the command to create an exFAT file system on the volume /dev/sdd1:

mkfs.exfat /dev/sdd1 -b 4M -c 32k

where /dev/sdd1 - replace with the name of the partition of your disk / flash drive from the output of the lsblk command.

For a 32 GB microSD memory card, the command to create the exFAT file system.

sudo mkfs.exfat /dev/sdd -b 16M -c 128k

where /dev/sdd - replace with the name of the microSD memory card, which was output by the lsblk command.

Specifying the number of sectors per cluster in the "-s" parameter

Some Linux distributions (for example, Runtu LITE) have a variant of the mkfs.exfat program that requires you to specify only the number of sectors per cluster in the "-s" parameter, rather than the cluster size. The label parameter (-L name) is also missing.

To specify the cluster size in sectors, you first need to know the sector size:

lsblk
fdisk -l /dev/sdb

Disk /dev/sdb: 3.63 GiB, 3879731200 bytes, 7577600 sectors
Disk model: USB Flash Drive
Units: 1 sector * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

It can be seen that the physical sector size is 512 bytes.

Optimal sizes when specifying the -s parameter:

USB flash drive capacity, GB Optimal cluster size, KB Cluster size in sectors
(-s parameter)
1 - 2 32 -s 64
2 - 32 32 -s 64
32 - 128 128 -s 256
128 - 512 256 -s 512
512 - 2048 512 -s 1024

Example command for a 4GB flash drive

sudo mkfs.exfat /dev/sdb1 -s 64    

Typical mistakes when partitioning and using Flash disks

The main problem that may arise is the failure of the flash disk if the partition table is deleted and another partition table is created in its place (for example, when executing the command dd id=file.iso of=/dev/sdc). Some USB flash drives can only work with a factory-created partition table and cannot tolerate changing it. You can only format such “flash drives” in exFAT without changing the structure. A sign of flash drive failure is the message “no media available.” In this case, the controller is recognized from the computer when it is connected to the USB socket, but the internal memory of the media is not visible (Volume 0 bytes, 0 bytes free).

A “dead” flash drive cannot be restored using Windows or Linux commands (only special low-level programs from manufacturers can help, which directly access the controllers, indicating the parameters of the memory chips. Such programs are often not compatible with the installed controller, and have a complex interface that requires specifying the exact type of controller (you can find out by disassembling the Flash drive).

List of portable storage devices that fail when executing a DD command or deleting a partition table using parted:

  • ADATA C008 [AC008-8G-RKD]
  • фUSB cables from Aliexpress with two USB and micro-USB connectors (Chipsbank CBM2199E controller chip). Inscription on the printed circuit board: CBM2199. Possibly other models of Chipsbank flash drives.

Creating a disk partition table and formatting it as exFAT in Windows

cmd
diskpart

list disk
select disk 1
clean
list disk
create partition primary
active
format fs=exfat unit=32k label="Flash disk" quick
assign letter=f

Creating a disk partition table and formatting it to exFAT in Linux

First you need to install the necessary packages:

sudo apt-get update
sudo apt-get install gparted gnome-disk-utility

Now let's run the program:

sudo gparted

Next, follow the steps as in the screenshots below:

Replace the letters SDA with the drive name (SDD, SDE, etc.) corresponding to the portable drive - see command output lsblk.

1.
create0
2.
create1
3.
create2
4.
create3
5.
create4
6.
create5
7.
create6
8.
create7
9.
create8
10.
create9

To mount the disk, launch the Disks snap-in (sudo gnome-disks), select the disk, partition and click on the "triangle" button.
mount

The new disk is ready to go.

Mounting a drive with a different name

When you connect the drive to USB, the external drive is automatically mounted into a folder /media/username/label:
mounted

If you are not satisfied mount point name by default, it can be changed by clicking on the button with the image of two gears.
options

Disable the switch "User session defaults" =>Change the mount point.
change

Then, specify a different mount point:
backup

For the settings changes to be applied, in the "Disks" snap-in, unmount the disk (button with a square - "stop") and mount the disk again (button with a triangle).

backup2

The mount point has changed to /mnt/backup. The disk is visible in the "PCManFM" Explorer.

Correct disk ejection

Before physically disconnecting the drive, click on the "eject" icon in File Explorer.
unmount

Addition. Questions and answers.

Question: From what version of the kernel does exFAT support exist in Linux?

Answer: for low kernel versions 4.1 - 5.15 you can use a backport called linux-exfat-oot, which needs to be compiled and built into the kernel.

Native, i.e. "native" exFAT support with mounting disks in a graphical interface - with the kernel 5.19 and higher. (Source).

Also, in Android 9.0 "Pie" and higher (Android kernel 4.4.146+).

Question: Starting from what version of Ubuntu OS is support for exFAT FS implemented out of the box?

Answer:Ubuntu 20.10 and 22.04 LTS and newer ones too Linux Mint 21.x LTS based on 22.04.

Source 1,Source 2

What is the purpose of the exfat-fuse package?

Answer: The exfat-fuse package is used for the FUSE modular file system for the user environment of the Ubuntu OS version below 22.04.

In Ubunti OS 20.04 LTS and earlier, you need to additionally install the module exfat-fuse.

sudo apt install exfat-fuse

Check:

uname -r
lsb_release -a

If the kernel is higher than 5.19 and OS 22.04 LTS, then the package exfat-fuse is not required, it must be removed.

sudo apt remove exfat-fuse

How to check for exFAT support at the kernel module level?

Answer:

find /lib/modules/ -iname '*exfat*'

How to check exFAT support in older OS (before Ubuntu 20.10)?

The package is responsible for exFAT support in older OSes exfat-fuse for the FUSE modular file system:

dpkg -s exfat-fuse

This package can be installed separately with a command that will enable exFAT support for older Linux operating systems:

sudo apt-get install exfat-fuse

Question: Which package contains utilities for working with exFAT?

Answer:exfatprogs.

sudo apt install  exfatprogs

exfat-fuse - tools for creating, validating and marking exFAT file systems.

Tools for managing the extended file system allocation table.
This package provides tools for creating, validating, and marking a file system.
It contains
- mkfs.exfat to create exFAT file system
- fsck.exfat to check and repair the exFAT file system
- tune.exfat for printing and editing the file system label
The tools included in this package are exfatprogs,
maintained by Samsung engineers who provided support for Linux exFAT.
A similar but independent implementation of these tools, written by the author of the exfat-fuse implementation,
available in the exfat-utils package.
Home page:https://github.com/exfatprogs/exfatprogs.

Question: How can I assign a new label to a disk without formatting it?

Answer:

sudo sudo exfatlabel /dev/sdd1 "Disk Label" 

Question: How long should an exFAT disk label be?

Answer: theoretically 15 characters, but for compatibility with exFAT 1.0 a length of 11 characters was chosen, the rest are reserved.
Correct:0 - 11 characters.

Question: What should I do if, when running exfatlabel, the following message is displayed:
"open failed : /dev/sdd, Device or resource busy"

Answer: you need to find out the device name of the external drive:

mount | grep fat

Unmount the volume (in this case sdd1):

sudo umount /dev/sdd1

Repeat the "exfatlabel" command for volume sdd1:

sudo exfatlabel /dev/sdd1 "Cruizer_8Gb" 

Disconnect the drive from the USB socket and connect it again.
The disk is now mounted with a new label.

Who holds the patent for the exFAT file system?

СпеExtended File Allocation Table (exFAT) file system specification was developed by Microsoft Corporation and is protected by several patents, including US Patent No. 2009/0164440 A1. All implementations of the exFAT file system, including those based on open source code (such as Linux, Android, FATfs or others), are subject to royalties to Microsoft. This means that if you develop and ship a product that includes any functionality covered by exFAT patents, regardless of where the code comes from, you are required to pay royalties before publishing the product to comply with Microsoft's licensing terms.Source

Sources:
man mkfs.exfat.8
https://en.wikipedia.org/wiki/ExFAT

Last edit: 02/06/2025