Format USB as exFAT with fdisk

To format a drive to exFAT using fdisk, follow these steps:

  1. Identify the correct device. Insert the USB drive or external disk and use the command sudo fdisk -l to list all storage devices and their partitions. Carefully identify the correct device (e.g., /dev/sdb) and partition (e.g., /dev/sdb1) you wish to format, ensuring you do not select your system's boot drive
  2. Create a new partition table and partition. Run sudo fdisk /dev/sdX (replace sdX with your device identifier, e.g., sdb). In the fdisk menu, type o to create a new DOS partition table Then, type n to create a new partition, and press Enter twice to accept the default first and last sectors, creating a single partition that uses the entire drive
  3. Set the partition type to exFAT. In the fdisk menu, type t to change the partition type. Enter 7 to set the type to HPFS/NTFS/exFAT For drives larger than 2TB using a GPT partition table, the correct type is Microsoft Basic Data (GUID: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7), which can be set using gdisk instead of fdisk
  4. Write the changes to the disk. Type w to write the partition table to the disk and exit fdisk. Confirm the action when prompted
  5. Format the partition with the exFAT filesystem. Use the mkfs.exfat command to create the filesystem on the newly created partition. Replace /dev/sdXn with your actual partition (e.g., /dev/sdb1) and LABEL with your desired volume name. The command is sudo mkfs.exfat -n "LABEL" /dev/sdXn This command formats the partition and creates the exFAT filesystem
  6. (Optional) Verify the formatting. You can check the filesystem for errors using sudo fsck.exfat /dev/sdXn A successful check will report "File system checking finished. No errors found."

Note: For Linux kernels 5.4 and later, exFAT support is built into the kernel, so you only need the exfat-utils package. On older systems, you might need exfatprogs Ensure the necessary tools are installed with sudo apt-get install exfat-utils or sudo apt install exfatprogs