Since 2016 · 50,000+ customers · ★ 5.0 on Google Live chatWhatsAppTelegramOpen a ticket
Get started
Linux

How to Format a USB Drive in Linux (GUI and Terminal)

How to format a USB drive in Linux by 99RDP

Formatting a USB drive erases it and creates a fresh filesystem, which fixes many errors and lets you choose a format that works with Windows, macOS or Linux. On Linux you can do it with a graphical tool in a few clicks or from the terminal with mkfs. This guide explains which filesystem to choose, how to format with GNOME Disks and KDE Partition Manager, how to format from the command line (including creating a new partition table), and how to fix a drive that will not format.

Quick answerFind the drive with lsblk, unmount it, then format the partition, for example as exFAT:

lsblk
sudo umount /dev/sdb1
sudo mkfs.exfat -n MYUSB /dev/sdb1

Double-check the device name: formatting the wrong disk destroys its data.

Which filesystem should you choose?

FilesystemWorks withMax file sizeUse it for
exFATWindows, macOS, Linux, most TVs and camerasPractically unlimitedThe best general choice for sharing drives
FAT32 (vfat)Almost everything, including old devices and UEFI boot4 GBSmall drives, car stereos, firmware updates
NTFSWindows; Linux reads and writes; macOS read-onlyVery largeDrives used mainly with Windows
ext4LinuxVery largeDrives used only with Linux, backups with Linux permissions

Before you start

  • Copy anything you want to keep from the drive. Formatting erases it.
  • Install the tools for the formats you need: sudo apt install exfatprogs dosfstools ntfs-3g (on Fedora, use dnf).
Checklist for safely formatting a USB drive in Linux: identify the right device, back up and unmount first
Check twice, format once

Method 1: GNOME Disks

  1. Open Disks (install with sudo apt install gnome-disk-utility if missing).
  2. Select your USB drive in the left panel. Check the size and model.
  3. To format one partition: select it, click the gear icon and choose Format Partition.
  4. Enter a volume name and choose a type: "For use with all systems and devices (FAT)", "For use with Windows (NTFS)", "Internal disk for use with Linux systems only (Ext4)", or Other for exFAT.
  5. Click Next, then Format.

To wipe the whole drive and start over, use the menu at the top right and choose Format Disk, then create a new partition with the + button.

Method 2: KDE Partition Manager or GParted

On KDE, open KDE Partition Manager; on other desktops, GParted (sudo apt install gparted). Select the USB device from the drop-down at the top, unmount its partition, right-click it and choose Format as (GParted) or Edit/Format, pick the filesystem, and apply the changes.

Method 3: Command line

Step 1: Identify the drive

lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINTS

Find your USB drive by size, for example sdb with partition sdb1. Your system disk is usually sda or nvme0n1; do not touch it.

Step 2: Unmount it

sudo umount /dev/sdb1

If the drive has several partitions, unmount each one (sudo umount /dev/sdb?).

Step 3: Format the partition

sudo mkfs.exfat -n MYUSB /dev/sdb1          # exFAT
sudo mkfs.vfat -F 32 -n MYUSB /dev/sdb1     # FAT32 (label up to 11 characters)
sudo mkfs.ntfs -f -L MYUSB /dev/sdb1        # NTFS (quick format)
sudo mkfs.ext4 -L MYUSB /dev/sdb1           # ext4

Note that you format the partition (sdb1), not the whole disk (sdb).

Optional: create a new partition table first

If the drive was used as a bootable installer or has a strange layout, recreate its partition table with one partition covering the whole drive:

sudo wipefs -a /dev/sdb
sudo parted /dev/sdb --script mklabel gpt mkpart primary 1MiB 100%
sudo mkfs.exfat -n MYUSB /dev/sdb1

Use mklabel msdos instead of gpt for very old devices that only understand MBR.

Step 4: Check the result

lsblk -f /dev/sdb
Steps to format a USB drive from the terminal: identify, unmount, partition, create the filesystem and check
Formatting from the terminal

Securely erasing a drive

A normal format leaves old data recoverable. To overwrite everything before giving a drive away:

sudo dd if=/dev/zero of=/dev/sdb bs=4M status=progress

This writes zeros over the entire device and then needs a new partition table and format. It takes a long time on large drives, and on flash memory some old blocks may survive; physical destruction is the only guarantee for very sensitive data.

Comparison of ways to erase a USB drive: quick format, wipefs, zero fill and the drive secure erase
How thorough is the erase?

Troubleshooting

  • "Device or resource busy": a partition is still mounted or a program is using it. Unmount it and close file managers.
  • "mkfs.exfat: command not found": install exfatprogs.
  • Drive is read-only: check for a physical lock switch, and look at dmesg; a drive that switched itself to read-only is often failing.
  • Wrong size shown (for example after writing an ISO): recreate the partition table as shown above.

Frequently asked questions

What format should a USB drive be for Linux and Windows?

exFAT. It works on Windows, macOS and Linux and has no 4 GB file size limit.

How do I format a USB drive to FAT32 in Linux?

Unmount it and run sudo mkfs.vfat -F 32 /dev/sdb1, replacing sdb1 with your partition.

Can I format a USB drive in the Linux terminal without losing data?

No. Formatting erases the filesystem. Copy your files elsewhere first.

How do I make a bootable USB drive back into a normal one?

Wipe it with wipefs -a, create a new partition table with parted, and format the new partition.

Nishant Kumar, Sr. Server Engineer at 99RDP
Written byNishant KumarSr. Server Engineer, 99RDP. Part of the team that runs our servers and answers support.
Keep reading

More Linux guides

All Linux guides

Need a server for this?

✓ Setup in minutes✓ Full admin access✓ 7-day refund on new services