Paulo Teixeira

Software Engineer
How to format a USB Drive using the terminal on Debian, Ubuntu, or derivatives
Tips to daily tasks

05/12/2025 6 min

How to format a USB Drive using the terminal on Debian, Ubuntu, or derivatives

A practical guide on how to safely format a USB flash drive using the terminal on Ubuntu, Debian, and derivatives.

1) Identify the USB drive

First, list all block devices and identify which one is your USB drive.

lsblk -o NAME,LABEL,SIZE,RM,MODEL,TRAN

2) Unmount the USB drive

Before formatting, make sure the USB drive is not mounted.

sudo umount /dev/sdc* # replace /dev/sdc with your device

3) Clean existing signatures

Wipe old filesystem signatures so they don't confuse the system.

sudo wipefs -a /dev/sdc

Then create a new partition that uses 100% of the space:

sudo parted -a optimal /dev/sdc mkpart primary fat32 0% 100%

4) Format the USB drive

Format the new partition with FAT32 (good compatibility with most systems).

sudo mkfs.vfat -F 32 /dev/sdc1

5) Set a label (name) for the drive

Finally, give your USB drive a friendly label.

sudo fatlabel /dev/sdc1 PENDRIVE