Formatting a USB drive means erasing all the data and creating a new filesystem. It is the best way to prepare a USB drive for use on a computer system. After formating USB data stored in an organized way, this also optimizes the performance of the storage device. Formatting a storage device can fix a disk error.
You can easily format a drive using GUI but formatting it through a terminal requires extra knowledge of commands. Formatting a USB in your terminal is also useful when you want its low-level formatting.
In this article, I will discuss how to format a USB drive using a Linux terminal.
To follow this guide you should have the following –
- A system with Linux installed on it
- A USB drive
- Access to a user account with Sudo privileges
Formating USB drive using Linux terminal
Follow the given steps to format a USB drive from your terminal in Linux.
Attach the USB drive to your system
Plugin the USB drive into your Linux system and run the following command to list all the storage devices on it.
Here correctly identify the USB drive that you are going to format –
As you can see the USB attached to my system is
/dev/sdb1 which is mounted on
Unmount the USB drive
When you connect an external storage media to your system it gets automatically mounted in Linux. You can not format a mounted disk first you need to unmount it.
So use the following command to unmount the attached USB drive –
sudo umount /dev/sdb1
Format the USB drive
Once the USB drive gets unmounted you can now format it. There are many filesystems in which you can format a storage device but the most commonly used are –
- FAT32 – Supported file size is 4GB – 2 bytes and compatible with most of the systems
- NTFS – Max file size supported is 16 ExaBytes – 1KB, compatible with Windows, macOS, and most of the Linux distributions
- exFAT -Max file size supported is 16 ExaBytes – 1KB, compatible with Windows, Linux, macOS, etc
- Ext4 – Max file size supported is 1 ExaByte, compatible with Linux, macOS, and windows with additional programs
Now you can format your USB using one of the given filesystems.
Format with FAT32 file system
sudo mkfs.vfat /dev/sdb1
Format with exFat file System
sudo mkfs.exfat /dev/sdb1
Format with NTFS file System
sudo mkfs.ntfs /dev/sdb1
Format with EXT4 file System
sudo mkfs.ext4 /dev/sdb1
Similarly, you can format your USB drive using any other filesystem.
Mount the USB drive
Once you formatted your USB drive successfully now mount it to use on your system.
Create a mount point by using the given command –
sudo mkdir -p /media/usbdrive
Now use the following command to mount it –
sudo mount /dev/sdb1 /media/usbdrive
Now you will be able to use your USB drive.
Ok, so you have successfully formatted your USB drive. Now if you have a query then write us in the comments below.