Time and again, we need to format a USB drive in order to change the file system, to completely wipe off the data, or to get rid of a virus infecting it. There are various ways to format a USB drive, and we have listed a few in this article so that you can see which one works for you. You can format a USB both through the command line and the GUI, depending on what you are comfortable with.
The commands and procedure described in this article have been executed on an Ubuntu 18.04 LTS system.
Format USB Drive Through the Command Line
Formatting a USB drive is very simple through the command line. Even a beginner can format a USB drive through the simple process and commands we are describing here.
1. The first step is to identify the USB drive correctly in order to avoid formatting any other drive by accident. Open the Terminal application through the Dash or through the Ctrl+Alt+T shortcut and enter the following command:
$ df -h
The last line in the output lists /dev/sdb1 as our USB drive.
2. Use the following command in order to format the USB as per the VFAT file system:
$ sudo mkfs.vfat /dev/sdb1
You will be using the location as per the output you got from the df -h command.
3. You can only format an unmounted USB drive, otherwise, you will get the following message:
Therefore, please unmount the drive through the following command:
$ sudo umount /dev/sdb1
Now when you run the formatting command as a root user, your USB drive will be successfully formatted.
Format USB Drive Through the GUI
Format Directly from the File Manager
You can format a USB drive through the graphical interface of your Ubuntu system as follows:
1. Open the file manager and then right-click the USB drive name that you want to format, from the left pane.
2. Click the Format option from the right-click menu. The following dialog will open.
3. Specify a volume name for your USB drive. In the above image, we have entered USB as the Volume Name.
You can choose to erase the existing data on your USB drive by switching on the Erase button. In that case, the existing data on your system will be overwritten and the formatting process will take slightly longer time. You can also specify the file system you want the USB drive to have.
4. Click the Next button located in the top-right corner that only becomes active after you have provided all the specifications.
The following Confirm Details dialog will open for you to confirm the formatting details. Please make sure you are formatting the right volume by viewing the Location information. This will prevent you from formatting any unwanted storage and thus corrupting your system.
4. Click the Format button after confirming the details.
Your USB drive will be formatted and ready for use, based on the volume name, file system, and data erasing options you specified.
Format USB Drive through the GParted tool
You can also format your USB drive through a tool called Gparted. Gparted in an open source partition editor for Linux systems. Follow these steps to install and use this tool:
1. Open the Terminal through CTRL+ALT+T or through your Ubuntu Dash.
2. Enter the following command in order to install the open-source tool GParted:
$ sudo apt-get install gparted
3. Enter y when prompted by a y/n option for continuing installation.
The GParted tool will be installed on your system.
4. In order to access the GParted from your desktop, search for it through the Dash as follows:
5. Click on the GParted icon to open the application.
6. You will be asked to provide authentication for root user as only a root user can access and use this application. Provide the password and then click Authenticate.
The tool will open, displaying the /dev/sda partitions of the hard disk by default.
7. Since we want to view details of removable media, select that from the drop-down option located at the top-right corner. You will now be able to see the partitions of removable media as follows:
8. You need to unmount a USB drive before formatting it. Select the USB partition that you want to format, right-click and then click Unmount.
9. Now when you right-click the USB partition, the ‘Format to’ option will become active. Click the Format to option and then select a file system you want to use for your USB drive.
We have selected ntfs in this example. This operation will be added as a pending operation.
10. In order to apply this operation, click the tick icon from the top bar to apply all operations.
11. The following dialog will appear, asking you for confirmation about applying all the pending operations. Click the Apply button when you are sure about your choice.
The formatting process will begin:
You will be notified when the operations have been completed as follows:
12. Click the Close button; you now have a formatted USB drive with the file system you specified.
After reading this article, you might have figured out a way to format your USB drive for a better use. You can use both the command line or the user interface to format a USB drive after unmounting it. The powerful partition editing tool GParted will also help you to format your drive based on a long list of available file types.