Linux Notepad

Partition USB drive to FAT32 using fdisk (Debian 12)

=============================================
!!! FOR NOW, THIS GUIDE DOES NOT WORK !!!
=============================================

This guide explains how to partition and format USB storage devices (flash drives, external HDDs/SSDs) to the FAT32 filesystem on Linux systems.
FAT32 only supports files up to 4GB and drive sizes up to 2TB, but it provides cross-platform compatibility with modern operating systems: Windows, macOS, and Linux.

These instructions are specifically for Debian 12, but it should work on other Debian based Linux distributions with minimal modifications.

WARNING: Back up all important data before proceeding! Using incorrect device names can result in data loss.

Installing required packages

Install the necessary tools:

sudo apt update
sudo apt install dosfstools -y

The dosfstools package provides:

  • mkfs.fat - Creates FAT32 filesystems
  • fatlabel - Sets/gets filesystem labels
  • fsck.fat - Checks and repairs FAT32 filesystems

Partitioning and formatting process

1. Identify the USB device

List all storage devices:

sudo fdisk -l

Look for your USB device (usually /dev/sdX where X is a letter).

Example output:

Disk /dev/sda: 223.57 GiB, 240057409536 bytes, 468862128 sectors
Disk model: KINGSTON SA400S3
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x564726de

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1  *     2048 468860927 468858880 223.6G 83 Linux

Disk /dev/sdb: 7.23 GiB, 7759462400 bytes, 15155200 sectors
Disk model: TransMemory     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x76fd1384

Device     Boot Start     End Sectors  Size Id Type
/dev/sdb1  *        0 1292287 1292288  631M  0 Empty
/dev/sdb2        4524   23563   19040  9.3M ef EFI (FAT-12/16/32)

In this example, /dev/sda is the drive where Linux is installed, and /dev/sdb is the USB drive I will partition.

2. Create the new partition

sudo fdisk /dev/sdX  # Replace X with your device letter

Follow these steps:

  1. Type o to create a new empty MBR (DOS) partition table. This will delete all existing partitions.
  2. Type n for new partition
  3. Select p for primary
  4. Press Enter twice for default first/last sectors
  5. Type l to list available partition types.
  6. Type t to change the partition type.
  7. Type 0c for W95 FAT32 (LBA).
  8. Type w to write changes

3. Format to FAT32

Format the newly created partition:

sudo mkfs.vfat -F 32 /dev/sdX1  # Replace X with your device letter

The mkfs.vfat command creates the FAT32 filesystem.

4. Check the newly created filesystem (recommended)

Note: The partition might need to be unmounted before running the check command.

sudo fsck.fat /dev/sdX1

Example output:

fsck.fat 4.2 (2021-01-31)
/dev/sdb1: 0 files, 1/1890440 clusters

Resources

Back to homepage