How to format USB with exFAT on Linux

exFAT stands for Extensible File Allocation Table and is a format made by Microsoft for use on devices like USB flash drives. In general, you do not hear a lot about exFAT these days, but it remains a viable format that is compatible with Windows, MacOS, and Linux, so it is a good choice for a flash drive that you plan on using with a variety of different systems. Some manufacturers even use exFAT as the default format for their SD cards or other products.

exFAT has a lot of the advantages of FAT, such as a small overhead, but is not burdened by the same limitations. It is therefore able to support very large volume and file sizes like other modern formats. In this tutorial, we will show you how to format a USB drive with exFAT on a Linux system.

In this tutorial you will learn:

  • How to install the exFAT format on all major Linux distros
  • How to format a USB drive with exFAT via GUI
  • How to format a USB drive with exFAT via command line
How to format USB with exFAT on Linux
How to format USB with exFAT on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software exfat-fuse, fdisk, gdisk
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to Enable exFAT formatting on major Linux distros




Some Linux distributions do not have the ability to format a drive with exFAT by default. However, we can install a package from the official repository on any major Linux distro that enables us to use the exFAT format.

You can use the appropriate command below to install exFAT formatting utility with your system’s package manager.

To install exFAT formatting utility on Ubuntu, Debian, and Linux Mint:

$ sudo apt update
$ sudo apt install exfat-fuse

To install exFAT formatting utility on Fedora, CentOS, AlmaLinux, and Red Hat:

$ sudo dnf install exfatprogs

To install exFAT formatting utility on Arch Linux and Manjaro:

$ sudo pacman -S exfat-utils
WARNING
Formatting the flash drive with exFAT will delete all data on it, unless you are only formatting one partition on the drive and have all your data on a different one. In our tutorial, we will be erasing the whole disk before creating an exFAT partition, so it is strongly recommended that you create a backup of your flash drive before continuing.

Format USB with exFAT via GUI

Depending on what Linux distribution or desktop environment you are using, the screenshots below may not match up with exactly what you see on your own screen. We are using Ubuntu Linux in these steps, but the process should be mostly the same no matter what distro you are on. The key point is that you will need to find and open your operating system’s disk utility software.

  1. Once you have inserted the USB flash drive disk into the computer, get started by opening your system’s disk management application.



    Open the disk utility software from the application launcher
    Open the disk utility software from the application launcher

  2. You should see your USB flash drive disk listed among the other storage devices on your system. Make sure you select the one that you wish to format.
    The disk is listed among the other storarge devices on the system
    The disk is listed among the other storarge devices on the system
  3. You will have several options on what to do with this flash drive. Click the one that says “Format Disk” or something similar.
    Select to format your USB flash drive
    Select to format your USB flash drive
  4. On our test system, we have a few different options for erasing and partitioning our USB thumb drive. A quick format will not securely erase the current data on the disk but it will perform the formatting very quickly, as the name implies. The other option is to rewrite the disk with all zeros (not necessary in the majority of situations). You can also create a MBR or GPT table, or apply no partitioning. If you are not sure, just leave the defaults selected and click “Format.”
    Choose formatting options or simply leave the defaults selected
    Choose formatting options or simply leave the defaults selected
  5. As mentioned earlier in the guide, this process will completely erase the contents in your USB flash drive. The formatting software warns us once again to make sure we are aware, then it wipes the drive completely.
    Confirmation box about wiping all data on the USB flash drive
    Confirmation box about wiping all data on the USB flash drive
  6. Next, we will add a new exFAT partition to our USB flash drive. In our application, we click on the plus sign to add a new partition. Click the appropriate option in your software.
    Click to add a new partition
    Click to add a new partition
  7. Next, select the partition size. In our case, we will let our partition take up the entire USB disk. It is up to you if you want to allow additional room for adding other partitions later on.

    Select the desired size of the partition
    Select the desired size of the partition



  8. In the next menu, we need to select “other” when it asks what kind of file format we want to use. Remember, exFAT is not a particularly common format, so the choice is sometimes hidden under an additional prompt.
    Select to format with a different format than the ones listed here
    Select to format with a different format than the ones listed here
  9. Choose the exFAT format and then click Next.
    Choose to format the partition with exFAT
    Choose to format the partition with exFAT
  10. When the process is done, we can confirm that our partition has indeed been formatted with exFAT.
    The disks program shows that our partition is not formatted with exFAT
    The disks program shows that our partition is not formatted with exFAT

Format USB with exFAT via command line

Once you have inserted the USB flash drive into your computer, open a terminal and type the following commands to format it with exFAT:

  1. First, let us figure out how to identify the media we wish to format. The name should start with /dev/sd and then a letter. Type the following command in terminal to see:
    $ sudo fdisk -l
    

    Find your device name in the fdisk output
    Find your device name in the fdisk output



  2. In our example, the USB disk has been assigned /dev/sdb. To create a new partition on the empty USB flash drive, we will provide it as an argument to the gdisk utility:
    $ sudo gdisk /dev/sdX
    
  3. The gdisk utility awaits our commands. We would like to create a new partition, so we press n.
    Command (? for help): n
    
  4. This will be the first partition that we are creating on this USB flash drive, so the answer to the next question is 1.
    Partition number (1-128, default 1): 1
    
  5. The next questions are about first and last sector, which will determine the actual size of the partition. In our example we are creating a single partition that will cover the entire USB flash drive, and default values are first partition, first available sector to start, and last sector to end with, which is just what we need. So we will accept the defaults for these questions by simply pressing the Enter key.
    First sector (34-6291455966, default = 2048) or {+-}size{KMGTP}: 
    Last sector (2048-6291455966, default = 6291455966) or {+-}size{KMGTP}:
    
  6. The next question asks us what kind of file system this partition will be for. We need to enter a hex code that corresponds to our selection. However, the default response is ‘Linux filesystem’ which is exactly what we need. We will once again press the Enter key to accept this default value.
    Current type is 8300 (Linux filesystem)
    Hex code or GUID (L to show codes, Enter = 8300):
    Changed type of partition to 'Linux filesystem'
    



  7. The partition is now complete, but as the utility points out on start, the changes are in memory only until we write them out to the USB disk. This is on purpose and the warning is in place for a good reason: by writing out the changes to the flash drive, we destroy anything that resided on the sector range we cover with our new partition. We are sure there will be no data loss, so we write the changes to disk with the w command:
    Command (? for help): w
    
    Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
    PARTITIONS!!
    
    Do you want to proceed? (Y/N): y
    OK; writing new GUID partition table (GPT) to /dev/sdb.
    The operation has completed successfully.
    

    You will also need to reply Y to the confirmation prompt to verify that you indeed want to write these changes to the disk, and overwrite existing data.

    We are finished partitioning the USB flash drive with the gdisk utility
    We are finished partitioning the USB flash drive with the gdisk utility
  8. Since our block device is /dev/sdb, and we just created partition number 1 on the USB drive, that means our new partition is accessible under the path /dev/sdb1. Next, we still need to add a file system to our USB drive. Use the mkfs command to format the flash drive with the exFAT file system.
    $ sudo mkfs -t exfat /dev/sdX1
    
    Formatting our USB flash drive with exFAT via the mkfs command on Linux
    Formatting our USB flash drive with exFAT via the mkfs command on Linux
  9. We will now use the mount command to mount the newly formatted partition on our system. We will mount our flash disk drive to the /media/flashdrive directory.
    $ sudo mkdir -p /media/flashdrive
    $ sudo mount /dev/sdb1 /media/flashdrive
    

That is all there is to it. You can now access your newly formatted exFAT flash drive under the /mount/flashdrive directory or where ever you decided to mount it. To make the USB drive get mounted automatically, see our guide on configuring the /etc/fstab file.

Closing Thoughts




In this tutorial, we saw how to format and partition a USB flash drive with the exFAT format from command line and GUI on a Linux system. Managing partitions is a dangerous task that should be performed with the utmost caution. Your flash drive should now be usable across major operating systems like Windows, MacOS, and Linux, and the exFAT format is both fast and capable of handling large files and volume sizes.



Comments and Discussions
Linux Forum