format usb in linux

How to Format USB Drives in Linux

USB drives are portable storage devices that allow you to carry files & software with you wherever you go. But before you store any file on USB drive you need to format it the right way to be able to optimally use it. Sometimes you may need to format USB drive if it gets corrupted too. Ultimately, formatting USB drive prepares it for use in a computer, and organizes data to allow more free space and optimal performance. There are various ways to format USB drives in Linux. In this article, we will look at how to format USB drive using terminal.

How to Format USB Drives in Linux

There are basically 4 steps to format USB drive – you need to locate the drive, unmount & format the drive, and verify the formatting. You can format USB drive via terminal or command line tool like disk utility, or GUI tools like GParted. Also, you can format a USB drive in 3 disk formats – FAT32, NTFS, and exFAT.

1. Locate the USB disk

Open terminal and run the following command to locate USB drive.

$ df

The above command will list all mounted partitions along with relevant information such path, used space, available space and space percentage.

If you are not sure about the drive partition, remove the USB disk from temporarily and run the df command again. The partition that is not present in the output this time, is the USB drive.

2. Unmount disk

If you have recognized, say, /dev/sdb partition to be your USB drive, then run the following command to unmount it. Unless you unmount it, Linux won’t allow you to perform any operations on it. Replace /dev/sdb1 with your partition path.

$ sudo umount /dev/sdb1

3. Format disk

Once you have unmounted your USB drive, you can format it using the following command.


$ sudo mkfs.vfat /dev/sdb1


$ sudo mkfs.ntfs /dev/sdb1


$ sudo mkfs.exfat /dev/sdb1

4. Verify disk partition

Finally, verify disk partition using the following command.

$ sudo fsck /dev/sdb1

You will see the following kind of output indicating its format.

fsck from util-linux 2.34
fsck.fat 4.1 (2021-10-25)
/dev/sdb1:0 files, 1/4000002 clusters

That’s it. In this article, we have learnt how to format USB drive in Linux. You can use these commands on almost every Linux system since they are available on them all.

Also read:

How to Convert Epoch to Date in Linux
How to View Linux Log Files
How to Convert Files to UTF-8 in Linux
How to Set or Change Hostname in CentOS/RHEL
How to Convert Webpage to PDF in Linux

Leave a Reply

Your email address will not be published.