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 filesystemsfatlabel
- Sets/gets filesystem labelsfsck.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:
- Type
o
to create a new empty MBR (DOS) partition table. This will delete all existing partitions. - Type
n
for new partition - Select
p
for primary - Press
Enter
twice for default first/last sectors - Type
l
to list available partition types. - Type
t
to change the partition type. - Type
0c
forW95 FAT32 (LBA)
. - 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
- parted(8) manual
- fdisk(8) manual
- mkfs.fat(8) manual
- fatlabel(8) manual