Formatting USB Drives in Linux

Formatting USB Drives in Linux

A USB drive you have finished using can be prepared for files again on a Linux computer. Formatting creates a filesystem on a partition, which gives Linux a structure for organizing files on the drive.

This article explains how to identify the right USB partition and format it with a suitable filesystem.

TL;DR: Format a USB Drive Safely

To format a USB drive, identify the whole disk, unmount its partition, then create a filesystem on the partition you intend to erase. Formatting removes access to the files already on that partition, so copy anything you need before continuing.

  • Use exFAT for sharing large files across Linux, macOS and Windows. Choose FAT32 when older devices need compatibility.
  • Use ext4 when the drive will stay with Linux systems.
  • Check the device size and partition name before running a formatting command.

The command-line example below formats an existing partition. Use GParted if you need a graphical view or must create a new partition table. If a USB drive will move between systems, check the target device manual for its supported filesystems before choosing a format.

What Does Formatting a USB Drive Change?

A USB drive is the physical storage device. A partition is a region on that device, and a filesystem is the structure that organizes files inside a partition.

For a common drive with one partition, Linux may show a whole-device name such as /dev/sdb and a partition such as /dev/sdb1. Device names depend on the current connection.

FilesystemChoose it whenTrade-off
FAT32Older devices and broad compatibility matterIndividual files cannot exceed 4 GB
exFATSharing files across Linux, macOS and Windows, including large filesSome older devices may not support it
ext4The drive is for Linux systemsMany consumer devices and Windows installations do not read it by default
NTFSThe drive is used mainly with WindowsLinux support depends on the system’s available driver and tools

For shared storage, exFAT supports files beyond FAT32’s per-file limit when the receiving devices accept it.

I use the filesystem matrix to decide before erasing the drive because choosing for the receiving device prevents a format that the next computer cannot read. A filesystem is the on-disk format, while a partition table records where partitions begin and end. That distinction helps explain why a format operation on one partition is narrower than replacing the table for the whole drive.

How to Format a USB Drive in Linux Step by Step

Before using it, back up the drive, connect it, and identify its device and partition names. Stop if the size or model does not clearly identify the USB drive. In this procedure, the whole-device path names the removable drive, while the partition path selects the area that receives the filesystem.

Step 1: Identify the USB device and partition

Run lsblk to view block devices, their sizes, their partitions and mount points. The TYPE column distinguishes a disk from a partition, and MOUNTPOINTS shows whether Linux has attached a filesystem to a directory. I request explicit columns because the default lsblk output can vary across versions.

lsblk -o NAME,MODEL,SIZE,TYPE,FSTYPE,MOUNTPOINTS

Match the removable device by its model and capacity, then note the partition name beneath it. For example, if the confirmed USB disk is /dev/sdb, its first partition could be /dev/sdb1. Do not copy those sample names into a command until your own output confirms them.

A removable flag can offer another clue, but it is not a substitute for checking the model and size. Some card readers and USB enclosures report that flag differently.

If the output is unclear, unplug the USB drive, run lsblk again, reconnect it and compare the lists.

The MODEL and SIZE columns are useful together. Some enclosures report an unhelpful model string, so compare the listed capacity and the change in the device tree as well. If you cannot identify one drive with confidence, stop before formatting anything.

Step 2: Confirm the backup and unmount the partition

Close files and terminal windows that use the USB drive. If its partition has a mount point, unmount that partition before formatting. Replace the example with the confirmed partition name.

sudo umount /dev/sdb1

A busy error means that a process still has a file open on the drive or is using its mount directory. Close that application, move the shell’s current directory off the drive, and retry. Do not force an unmount as a shortcut.

The mount point is a directory where Linux makes the filesystem available to applications. A file manager can mount a removable drive automatically when you open it, so close file browser windows too. If the partition has multiple mount points, inspect all of them before proceeding.

Step 3: Create the filesystem on the partition

Use the formatter for your selected filesystem on the confirmed partition. For FAT32, the command is mkfs.fat. On many Linux distributions, mkfs.vfat is an alias for the same tool.

sudo mkfs.fat -F 32 /dev/sdb1

Substitute your verified partition for /dev/sdb1.

To create exFAT or ext4 instead, use the matching formatter only after confirming that its package and command are available on your distribution. For example, the formatter names are mkfs.exfat and mkfs.ext4. Do not run multiple formatter commands on the same target.

On Debian-based systems the FAT utility may be provided by dosfstools, while exFAT creation tools are packaged separately. Package names vary, so use your distribution documentation rather than copying an install command for another system.

Step 4: Verify the new filesystem

Ask lsblk to show the filesystem type and mount information again. The selected partition should show the filesystem you created. It may have no mount point until you mount it or open it in the file manager.

If the FSTYPE column is blank, confirm that the formatter completed and that you are inspecting the partition rather than its parent disk.

The label and UUID can also help identify a filesystem, but they are secondary checks and may be absent.

lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINTS

After verification, you can mount the partition from your desktop file manager and copy a small test file to it, then read that file back.

Unmount or eject the drive through the desktop before removing it so pending writes can finish. A filesystem check is a different task from checking that the new filesystem type appears. If you need to repair an existing Linux filesystem, see the Linux fsck guide.

USB Formatting Problems and Fixes

When formatting fails, check the mount state, filesystem tool and drive condition before retrying. I would inspect the cause before repeating a write operation because another attempt can erase the data you want to keep.

SymptomLikely causeNext check
Device or resource busyA partition is mounted or in useClose files using it, then inspect MOUNTPOINTS in lsblk
Formatter command not foundThe filesystem tools are not installedCheck the distribution’s package documentation for the required formatter
FAT32 rejects a large fileFAT32 has a per-file limit of 4 GBChoose exFAT if the target devices support it
Drive remains read-onlyHardware write protection or device/media failureCheck a physical lock switch where present and inspect system logs. Do not assume reformatting clears hardware protection
Drive appears with unexpected partitionsIt may have been used as boot media or have a different layoutInspect the full device in a partition editor before replacing its layout

If the formatter is missing, first confirm the exact filesystem type you intend to create. Then consult your distribution’s package documentation for that filesystem’s creation tools. FAT, exFAT and ext4 use different utilities, and installing an unrelated tool will not make the requested formatter available.

FAT32’s file-size limit matters when moving a single archive, disk image or video larger than 4 GB. The drive can still have free space while refusing that individual file. Reformatting to exFAT can address the limit when the receiving device supports exFAT, but changing a filesystem erases its existing contents.

A read-only device may have a physical lock on an SD adapter or a storage fault. Check any physical switch first. If write protection remains, inspect system messages and test another port.

A failing flash controller needs replacement, not formatting.

A USB drive used to create installation media can contain several partitions or a layout that does not appear as one ordinary volume. GParted shows the complete device map. Review its device selector and queued operations, since replacing the partition table acts on the whole drive and removes its existing layout.

If you still need files on a drive that reports errors, pause before formatting. Recovery and filesystem repair address a different problem, and new writes can reduce recovery options. The Linux fsck guide covers checks for supported Linux filesystems, including the need to check an unmounted partition.

GParted is my choice when the partition layout needs inspection because its device view makes pending whole-disk operations visible before they are applied. Select the USB drive, unmount its target partition, select the filesystem, inspect the operation list, then apply only after confirming the selected device. The GParted manual documents the data-loss risk.

For creating installation media rather than an ordinary data volume, follow the separate Ubuntu bootable USB guide.

Further file-system checks and official GParted instructions are linked above.

Conclusion: Check the Target Before Formatting

Formatting a USB drive in Linux comes down to identifying the correct disk, unmounting its partition, formatting it with the selected filesystem and verifying the result.

FAQ

These answers cover the filesystem and device questions that commonly come up during a format.

Which filesystem should I use for a USB drive?

Use exFAT for sharing large files across current Linux, macOS, and Windows systems when the target devices support it. Choose FAT32 for older-device compatibility, or ext4 for Linux-only use.

Should I format the whole USB device or its partition?

For a drive with an existing partition, format the partition, such as /dev/sdb1, not the whole device such as /dev/sdb. Recreate the partition table only when you intend to replace the drive’s layout.

Does formatting securely erase a USB drive?

No. A normal format creates new filesystem structures but does not guarantee secure erasure of old data on flash storage.