exFAT Compatibility in Ubuntu

exFAT Compatibility in Ubuntu
Users running Linux on Desktop often run into the problem or file system compatibility. Especially, when they are sharing data via a secondary storage device like an external hard disk or USB stick. The problem often originates because of the proprietary nature of file systems like exFAT and NTFS. The compatibility for exFAT or NTFS generally does not come for a distro out-of-the-box. Instead, you have to install additional packages to support these filesystem.

Things have changed since the inception of exFAT in 2006, the Ubuntu repositories now come with packages which support file systems like exFAT so you can share files across different operating systems with ease.

Concerning exFAT

exFAT file system is Microsoft’s attempt at revitalizing its ancient FAT (and FAT32) file systems to support USB devices. exFAT is designed to specifically manage files on flash storage media with large sizes of storage, such as external USB storage and SD cards.

When I say large storage devices, I mean devices with more than a mere 4GiB of raw storage. 4GiB is the memory limit for FAT32 file systems to overcome which exFAT (or extended FAT) was developed by Microsoft. Why not use NTFS you may ask?

When exFAT was created, way back in 2006, file system overheads where still a thing. So NTFS was not a feasible solution for small storage devices because NTFS itself took quite a bit of space. Additionally, exFAT is still a popular option for embedded systems because of its low power usage and simpler design which you can implement down at the firmware level resulting in better performance.

While most external drives are now NTFS, and you are probably better off formatting newer ones in that format, we still have quite a bit of existing devices that run on exFAT and so it is better to have an exFAT compatible system than to not have one.

exFAT compatibility

If you stick a USB drive which is formatted with exFAT file system to, say, a Ubuntu 18.04 system and try to mount it, you will get an error similar to this:

To overcome this issue, we can simply install exfat-utilis package which will enable us to create, label, read and write exFAT filesystem to any device node be it a USB device or a hard disk partition.

$ sudo apt install exfat-utils

If you want just the read and write capabilities, use the exfat-fuse package alone.

$ sudo apt install exfat-fuse

The latter is also installed as a part of exfat-utils dependency so you can read and write anyways. Once that package is installed you can mount your USB device without any issue using either the mount command using CLI or simply use the GUI.

Either way, it would not require any reboots and is quite a simple procedure.

About FUSE

You would notice that the exfat drive is named exfat-fuse. What does it mean? Filesystem in Userspace, or FUSE, means that the program that implements and manages exfat file systems runs in userspace as opposed to running in Kernel mode.

Storage management, like I/O and memory management, is a core responsibility of the operating system’s Kernel. Different file systems in the UNIX ethos come as different kernel modules and do their job in the kernel mode itself. FUSE lets filesystems to run as regular applications (like a text editor or a browser) in the userspace and FUSE, itself acts as a bridge between the Kernel and the filesystem. This doesn’t mean that you get to format arbitrary devices without root privileges.

For regular users, its distinction without a difference, but systems have a subtle way of breaking down and knowing simple facts about execution mode can save attentive sysadmins a lot of hassle.

Creating exFAT file systems

Let’s create a GPT label for a USB stick and format it with exfat file system. Assuming you have installed the utilities parted and exfat-utils using the corresponding apt get command, you are ready to follow along with the steps shown below.

First, use the parted utility to give the USB device a GPT (or MBR) label. We are sticking to GPT because it is industry standard. The USB device itself appears at the device node /dev/sdb and if you are in double you can use the command lsblk to list all the block devices and select the one that represents the storage capacity of your USB stick. Once the device node is know, let’s say it is /dev/sdb use the following command to open parted utility.

$ sudo parted -a optimal /dev/sdb
(parted) mklabel gpt

The second command with create a new gpt label. You will lose all the data in your USB stick, so be very careful and make sure that you have backup!  Then use command print to know the size of your storage device.

(parted) print

In the above screenshot, it is 4010MB in size. So let’s create a partition that spans the entire storage device.

(parted) unit MB
(parted) mkpart primary 1 4009

The one MB of space left before and after was something parted insisted on, in my specific case. Saying “the partion is not aligned for optimal performance” when I used 0 4010 as the starting and finishing points for my parition. You may have to experiment similarly.

Once the partition is made, you can safely quit the parted utility.

(parted) quit

Listing block devices, once again, would show you a new partition underneath the /dev/sdb device, this will be /dev/sdb1.

Now we simply call the mkfs.exfat utility to format this partition with exfat file system.

$ sudo mkfs.exfat /dev/sdb1

You can write some dummy files into this device, after mounting it (mounting can be done easily using the file system GUI). Try pluggin the same USB stick into a Windows system and if everything checks out, then you will be able to read from and write to this device without any issues.

Utility of exFAT

If you or your friends and colleagues use a Windows device alongside a Linux machine, formatting every storage media with EXT2,  EXT4, XFS or ZFS or any other UNIX file system might not be a great idea.

Things can get even worse if you use an SD card formatted with one of these file systems and use in your camera. An entire day’s worth of clicks would never have been recorded and you wouldn’t realize that. exFAT, like NTFS is easily supported on both Linux and Windows and is actively being maintained by Microsoft, ensuring widest range of applicability.

This makes exFAT a reliable bridge  to transfer data from one system to another, and we hope that this guide has helped you understand better how to accomplish that.

Related Posts
Leave a Reply

Your email address will not be published.Required fields are marked *