Formatting USB drives via command line takes only few steps and its easy.
Plug in your USB drive to the computer and run these following steps to format them.
1. View the mounted drives on system
You should get output something like this:
The command will list all currently mounted drives on system.
2. Unmount the USB drive that needs to be formatted
sudo umount /dev/sdb1
The ‘/dev/sdb1’ is the media drive where USB drive was mounted, see step 1. It can be different from you.
3. Format the drive
To FAT filesystem.
sudo mkdosfs -n 'MyDrive' -I /dev/sdb1
To FAT32 filesystem
sudo mkdosfs -n 'MyDrive' -I -F 32 /dev/sdb1
To Ext4 filesystem
sudo mkfs.ext4 -n 'Label' -I /dev/sdb1
mkdosfs : creates an MS-DOS file system under Linux
mkfs : build a Linux filesystem
n : Volume name
I : This switch will force mkdosfs to work properly
For more information on mkdosfs, use man mkdosfs.
Similarly, for more information on mkfs, use man mkfs.