Formatting a Universal Drive

This tutorial originally started out as a more detailed blog post. It received a lot of traffic from myself and others, but I only referenced the instructions at the very end. Therefore, I decided to pull out the important “how-to” bits and put them here for easier reference.

Objective

The following tutorial creates a GUID Partition Table (GPT) with an exFAT partition on a drive so that it can be read and written by all reasonably modern operating systems. The GPT/exFAT combination ensures support of filesystems over 2 TB in size and files over 4 GB in size. See the blog post for more details.

Prerequisites

Method

CAUTION. Be sure to back up any important data on your drive. The following commands will destroy all data on the drive.
% sudo gdisk /dev/sdX
GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

Command (? for help):

First, create a new GPT partition table with o:

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y

Now create a partition with n. The defaults will create a new partition that spans the whole drive with the first sector already aligned. Be sure to choose the correct type 0700!

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-16326462, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-16326462, default = 16326462) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 0700
Changed type of partition to 'Microsoft basic data'

Write the changes to the drive and exit with w:

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/sdX.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.

Finally, format our new partition with the exFAT filesystem.

Note. mkfs.exfat will use the following default cluster sizes depending on the volume size, but the -s flag can be used to provide a value manually.

If these values should change in future versions of mkfs.exfat, be sure to keep the cluster size not larger than 1024 KB (128 KB or 256 KB recommended) for compatibility with macOS.

Please refer to the manual (man mkfs.exfat) for more details.

% sudo mkfs.exfat /dev/sdX1
mkexfatfs 1.0.1
Creating... done.
Flushing... done.
File system created successfully.

The drive should now be readable and writable on Linux (via FUSE), macOS, and Windows.