Linux

How to Format a USB Flash Drive in Linux: Complete Guide

In this guide, you'll learn how to properly format a USB flash drive or external disk in Linux using both the command line and graphical interface. We'll cover filesystem selection, safe unmounting, and result verification.

Updated at February 16, 2026
10-15 min
Easy
FixPedia Team
Применимо к:Ubuntu 22.04+Fedora 36+Debian 11+Any modern Linux distro

Introduction / Why This Is Needed

Formatting a USB drive (flash drive or external hard disk) in Linux is a standard operation for preparing a device for use, resolving access issues, or changing the file system. This guide will help you safely format your drive by choosing the appropriate method: through a graphical interface or the terminal. You will learn how to identify the device, select a file system, and verify the result.

Requirements / Preparation

  1. A connected USB device to your computer.
  2. Administrator privileges (sudo) for operations via the terminal.
  3. To work with exFAT or NTFS file systems, some distributions may require installing additional packages:
    • exFAT: sudo apt install exfatprogs (Ubuntu/Debian) or sudo dnf install exfat-utils (Fedora).
    • NTFS: sudo apt install ntfs-3g (Ubuntu/Debian) or sudo dnf install ntfs-3g (Fedora).
  4. A backup of important data from the flash drive — formatting will permanently delete all files.

Method 1: Graphical Interface (GNOME Disks)

This is the simplest and most intuitive method, suitable for beginners in distributions with the GNOME desktop environment (Ubuntu, Fedora, Debian with GNOME).

Step 1: Open the "Disks" Utility

Find the "Disks" program in your application menu (or run gnome-disks in the terminal).

Step 2: Select Your USB Device

In the left panel listing devices, locate your flash drive. Pay attention to the model and size — this will help you avoid confusing it with your system disk.

Step 3: Erase Existing Data and Create a New Partition Table

⚠️ Important: This step will delete all partitions and data on the selected device.

  1. Click the menu button (three dots or an arrow) in the top-right corner of the device panel.
  2. Select "Format Disk...".
  3. In the dialog window, choose a partition scheme:
    • MBR — for compatibility with older systems (up to 2 TB).
    • GPT — the modern standard, recommended for disks larger than 2 TB and UEFI systems.
  4. Click "Format..." and confirm the action.

Step 4: Format the Created Partition

After erasing, the disk will show unallocated space.

  1. Click the "+" (Create Partition) button in the "Unallocated Space" section.
  2. Specify the partition size (you can leave the default to use the entire disk).
  3. In the "File System Type" field, select the desired type:
    • FAT (FAT32) — for maximum compatibility.
    • exFAT — for large files (>4 GB) and cross-platform use.
    • NTFS — for use with Windows.
  4. Give the partition a name (e.g., MYUSB).
  5. Click "Create". Formatting will begin automatically.

Step 5: Verification

After completion, the partition will mount and appear in your file manager. You can open it to confirm it is empty.


Method 2: Terminal (Command Line)

This method provides more control and is suitable for servers or systems without a graphical interface.

Step 1: Identify the Device Path

💡 Tip: Do not confuse /dev/sda (usually the system disk) and /dev/sdb (the second device, often a USB). A mistake will lead to data loss on your system disk!

Run the command:

lsblk

You will see a list of all block devices. Find your flash drive by its size (SIZE). The device path will look like /dev/sdX (disk) or /dev/sdXn (partition, e.g., /dev/sdb1).

Example output:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 238,5G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
└─sda2   8:2    0   238G  0 part /
sdb      8:16   1  28,7G  0 disk 
└─sdb1   8:17   1  28,7G  0 part /media/user/MYUSB  <-- Our flash drive

In this example, the device is /dev/sdb, and the partition is /dev/sdb1.

Step 2: Unmount the Partition (if it is mounted)

If the lsblk output shows a mount point for your partition in the MOUNTPOINT column, you need to unmount it:

sudo umount /dev/sdXn

For example: sudo umount /dev/sdb1. If the partition is not mounted, the command will issue a warning — this is not an error.

Step 3: Perform the Formatting

Use the mkfs command (make filesystem). Syntax:

sudo mkfs -t <filesystem_type> /dev/sdXn

Examples for different file systems:

  • FAT32 (4 GB file limit):
    sudo mkfs -t vfat /dev/sdb1
    
  • exFAT (recommended for modern needs):
    sudo mkfs.exfat /dev/sdb1
    
  • NTFS:
    sudo mkfs.ntfs /dev/sdb1
    
  • EXT4 (for Linux-only use):
    sudo mkfs.ext4 /dev/sdb1
    

⚠️ Important: Replace /dev/sdb1 with the path to your partition. Specifying the disk without a partition number (e.g., /dev/sdb) will erase all partitions on the device and create one new one.

Step 4: Verify the Result

  1. Check if the partition mounted automatically (it will appear in the file manager) or mount it manually:
    sudo mount /dev/sdXn /mnt
    
  2. Check the file system type:
    lsblk -f
    
    In the FSTYPE column for your partition, the selected type should be displayed (vfat, exfat, ntfs, ext4).

Verifying the Result

  1. Graphically: The device should appear in your file manager (Nautilus, Dolphin, etc.). Open it — the folder should be empty.
  2. Via terminal: Run lsblk -f and confirm that your partition (/dev/sdXn) shows the correct file system (FSTYPE).
  3. Try writing a file: Copy any small file to the flash drive and then delete it. This will confirm write functionality.

Possible Issues

  • Error: umount: /dev/sdXn: not mounted.
    • Cause: The partition is already unmounted.
    • Solution: You can skip the unmount step and proceed to formatting.
  • Error: mkfs: failed to create file system on /dev/sdXn.
    • Cause 1: The device is busy (mounted elsewhere or in use by the system).
    • Solution: Close all file managers and any windows showing files from the flash drive. Run sudo umount -l /dev/sdXn (lazy unmount) and try again.
    • Cause 2: Insufficient permissions (did not use sudo).
    • Solution: Add sudo at the beginning of the mkfs command.
  • Error: mkfs.vfat: No space left on device or Invalid argument
    • Cause: The partition you are trying to format is too small or has an unusual size (e.g., it was used for LVM).
    • Solution: Ensure you are specifying the correct path to the partition (e.g., /dev/sdb1), not the disk (/dev/sdb). If no partitions exist, create them first using fdisk or parted.
  • After formatting to exFAT/NTFS, the system does not mount the flash drive automatically.
    • Cause: Your distribution may not have the package installed to support that file system.
    • Solution: Install exfatprogs (for exFAT) or ntfs-3g (for NTFS), as indicated in the "Requirements" section. Reboot your computer or manually mount the partition: sudo mount -t exfat /dev/sdXn /mnt.
  • The flash drive formatted, but only part of the capacity is visible.
    • Cause: You formatted an old, small partition, and there is unused space on the device.
    • Solution: Use fdisk or parted in the terminal or the "Disks" utility to delete the old partition and create a new one that occupies all available space.

Additional Tips

  • Quick Format vs. Full Format: All described methods perform a quick format (only writing file system structures). For a full (slow) format that checks for bad blocks, use the -c option with mkfs (e.g., sudo mkfs.ext4 -c /dev/sdXn). This is useful for checking for bad sectors on an old flash drive.
  • Filename Encoding: For FAT32, the cp866 encoding is used by default (Cyrillic characters may not display correctly in Linux). When formatting via mkfs.vfat, you can specify the encoding: sudo mkfs.vfat -o iocharset=utf8 /dev/sdXn.
  • Labels (Volume Name): When formatting via the terminal, you can assign a volume label (name) immediately:
    sudo mkfs.exfat -n MYUSB /dev/sdb1
    
    In the graphical "Disks" utility, this field is called "Volume Name".

F.A.Q.

Is data erased when formatting a flash drive in Linux?
Which filesystem to choose for a flash drive: FAT32, exFAT, or NTFS?
Why can't I format the flash drive: 'device is busy'?
Can I format a flash drive without superuser privileges?

Hints

Identify the device and its path
Unmount the partition (if mounted)
Perform the formatting
Verify the result

Did this article help you solve the problem?

FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community