Skip to main content
3 of 3
added 2210 characters in body

How to format an exFAT filesystem on Linux with the desired cluster size to tune your selection along the tradeoff curve between speed and disk usage

Quick summary

Here's how to manually set your own cluster size. I recommend a cluster size of 8 KiB. The below information is a summary from my website here: https://gabrielstaples.com/exfat-clusters/#formatting-an-exfat-drive-on-linux-ubuntu:

  1. First, use gparted to prepare a partition. Format it to anything initially--ex: ext4. We'll change that later from the command line.

  2. Install dependencies. See: https://itsfoss.com/format-exfat-linux/

    sudo apt update 
    
    # For Ubuntu 20.04 and earlier
    sudo apt install exfat-fuse exfat-utils
    
    # For Ubuntu 22.04 and later
    sudo apt install exfat-fuse exfatprogs
    
  3. Ensure your partition you are about to format is NOT mounted:

    sudo umount /media/your_name/your_disk
    
  4. Format your partition as exFAT, setting the cluster size to 8 KiB.

    For the Ubuntu 20.04 case, this assumes your sector size is 512 bytes. The -s 16 argument says to use a cluster size of 16 sectors, which would be 16 sectors x 512 bytes/sector = 8192 bytes in a cluster. Note that you can change the -n "name" or -L "label" part to whatever you want your volume name to be, up to 15 chars (see man mkexfatfs):

    # For Ubuntu 20.04 and earlier
    # 8 KiB clusters (takes 0.698 sec) <=== WHAT I USE AND RECOMMEND
    time sudo mkexfatfs -n "my_exFAT" -s 16 /dev/sda999
    
    # For Ubuntu 22.04 and later
    # 8 KiB clusters <=== WHAT I USE AND RECOMMEND
    time sudo mkfs.exfat -L "my_exFAT" -c 8K /dev/sda999
    

    This just takes a few seconds.

  5. Done!

  6. For help, see:

    # For Ubuntu 20.04 and earlier
    # See this online here: https://man.archlinux.org/man/mkexfatfs.8.en
    man mkexfatfs
    
    # For Ubuntu 22.04 and later
    man mkfs.exfat
    mkfs.exfat -h
    

Details: cluster size, and mkexfatfs

Setting the cluster size is really important, it turns out, when formatting exFAT, as it significantly affects the speed and disk usage (see the plots I made, below).

If you use the Gnome Disks utility on Linux to format the exFAT drive, it chooses the cluster size for you, probably according to Microsoft's default values as shown in the table just below: Support.Microsoft.com: Default cluster size for NTFS, FAT, and exFAT:

Default cluster sizes for exFAT

The following table describes the default cluster sizes for exFAT.

Volume size Windows 7, Windows Server 2008 R2, Windows Server 2008,
Windows Vista, Windows Server 2003, Windows XP
7 MB–256 MB 4 KB
256 MB–32 GB 32 KB
32 GB–256 TB 128 KB
> 256 TB Not supported

When I used Gnome Disks to format my exFAT drive the first time, I realized later that it had used a cluster size of 128 KiB on my 500 GB SSD. This corresponds to the default values recommended by Microsoft in the table above.

If you'd like to use other cluster sizes, here are some more examples. YOu can use any power of 2 (to specify the number of sectors per cluster) after -s. The maximum cluster size allowed is 32 MiB, or 65536 512-byte sectors:

# Set the name after `-n` to whatever you want too. `-s` specifies how many
# sectors to use per cluster. Assuming you have 512 byte sectors, the following
# cluster size comments are accurate.
#
#                                                       cluster size  (format time)
#                                                       ----------    -------------
time sudo mkexfatfs -n "my_exFAT" -s 1 /dev/sda999     #   0.5 KiB (512 byte) 
                                                       #     clusters (10 sec)
time sudo mkexfatfs -n "my_exFAT" -s 8 /dev/sda999     #   4 KiB clusters (1.340 sec)
time sudo mkexfatfs -n "my_exFAT" -s 16 /dev/sda999    #   8 KiB clusters (0.698 sec) <=== WHAT I USE AND RECOMMEND: 8 KiB clusters
time sudo mkexfatfs -n "my_exFAT" -s 64 /dev/sda999    #  32 KiB clusters (0.230 sec)
time sudo mkexfatfs -n "my_exFAT" -s 256 /dev/sda999   # 128 KiB clusters (0.075 sec)
time sudo mkexfatfs -n "my_exFAT" -s 65536 /dev/sda999 # 32 MiB clusters (0.120 sec) [absolute max cluster size allowed!]

Here are the tradeoff curves of cluster size vs speed and disk usage, as I first presented on my website here: https://gabrielstaples.com/exfat-clusters/

enter image description here

Details: cluster size, and mkfs.exfat on Ubuntu 22.04 or later

man mkfs.exfat shows that the "SD Card Association" recommends the following cluster sizes for exFAT:

Card Capacity Range      Cluster Size   Boundary Unit
──────────────────────────────────────────────────────
            ≤8 MiB           8 KiB          8 KiB
  >8 MiB   ≤64 MiB          16 KiB         16 KiB
 >64 MiB  ≤256 MiB          16 KiB         32 KiB
>256 MiB    ≤1 GiB          16 KiB         64 KiB
  >1 GiB    ≤2 GiB          32 KiB         64 KiB
  >2 GiB   ≤32 GiB          32 KiB          4 MiB
 >32 GiB  ≤128 GiB         128 KiB         16 MiB
>128 GiB  ≤512 GiB         256 KiB         32 MiB
>512 GiB    ≤2 TiB         512 KiB         64 MiB

Again, though, I disagree with this, in particular for SSDs, and recommend 8 KiB cluster sizes. See my extensive analysis and speed and space testing here: https://gabrielstaples.com/exfat-clusters/.

Here are the commands to specify different cluster sizes with mkfs.exfat:

#                                                       cluster size
#                                                       ----------
time sudo mkfs.exfat -L "my_exFAT" -c 512  /dev/sda999  #   0.5 KiB (512 byte) clusters
time sudo mkfs.exfat -L "my_exFAT" -c 4K   /dev/sda999  #   4 KiB clusters
time sudo mkfs.exfat -L "my_exFAT" -c 8K   /dev/sda999  #   8 KiB clusters <=== WHAT I USE AND RECOMMEND: 8 KiB clusters
time sudo mkfs.exfat -L "my_exFAT" -c 32K  /dev/sda999  #  32 KiB clusters
time sudo mkfs.exfat -L "my_exFAT" -c 128K /dev/sda999  # 128 KiB clusters
time sudo mkfs.exfat -L "my_exFAT" -c 32M  /dev/sda999  # 32 MiB clusters

See also

  1. My answer: Is it best to reformat the hard drive to exFAT using 512kb chunk, or smaller or bigger chunks?
  2. My answer: Server Fault: How to find the cluster size of any filesystem, whether NTFS, Apple APFS, ext4, ext3, FAT, exFAT, etc.