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
- The following instructions use gdisk running on a Linux (or UNIX-like) operating system.
- The
exfat-fuse
andexfat-utils
packages are required to work with exFAT-formatted partitions on Ubuntu and similar distros. - The drive of interest has device path
/dev/sdX
for the purposes of this tutorial. Please be sure to substitute the device path for your own drive.
Method
% 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.
- 4 KB if the volume size is less than 256 MB,
- 32 KB if the volume size is between 256 MB and 32 GB, and
- 128 KB if the volume size is larger than 32 GB.
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.