How to Format a USB drive in Debian

Formatting a USB is a common operation in most computer systems and it comes in handy in a number of ways. For instance, you can format a USB drive if it gets infected with a virus, and data is corrupted or you want to change the file system as it is not compatible with your OS. Similarly, it can be helpful if you want to completely wipe off the old data so that you can fully use the storage space. So whatever the reason, you can easily format your USB device through different methods in a Debian operating system.

In this article, I will show you different methods to format a USB drive on the command-line and on Debian Desktop. You can use either of them based on your preferences.

Note that we have run the commands and procedure mentioned in this article on a Debian 10 system.

Format a USB Drive on the command-line

In order to format a USB through the command line, follow the procedure described here:

1. When you plug-in the USB drive, the Linux adds this device to the /dev directory. So our first step would be to identify the correct name of the USB drive to avoid mistakenly formatting any other device.

Open the Terminal by hitting the super key on your keyboard and search for it using the search bar at the top. In the Terminal, type the following command:

$ df –h

It will display the USB drive most probably at the end of the output. Like in our output, the USB drive is displayed as /dev/sdb1.

USB Drive

2. Now that you have identified the device name, first unmount the device otherwise, you will not be able to format it. Run the following command in the terminal to unmount the USB device.

$ sudo umount /dev/sdb1

Make sure to replace the /dev/sdb1 with the drive name you received from the df -h command.

Unmount device

3. Run the following command in Terminal to format the USB as per the VFAT file system:

$ sudo mkfs.vfat /dev/sdb1

If you want to format the USB drive as ntfs or ext3, you can do so by simply replace the vfat in the above command with the required file system.

Format USB Drive on Linux

Your USB drive will be successfully formatted based on the file system you specified.

GUI method to format USB Drive

In order to format a USB through GUI, here are two different ways :

Format Directly from the File Manager

In this method, we will be formatting the USB drive using the Debian  File Manager.

Open the File Manager in your Debian system. Then right-click the USB drive and select the Format option from the menu.

File manager

A Format Volume dialog box will open. In the Volume Name field, type a name for your USB drive; it will be the new label for your USB drive. Switch on the Erase button if you want to erase existing data on your system. By using this option, all your existing data will be overwritten and the process will take a little longer time. Also, choose the file system type. After that click the Next button located at the top right corner.

Choose filesystem type

The following Confirmation dialog box will appear. Confirm the information so that you do not format incorrect storage by mistake. After that, click the Format button.

Start formatting operation

Your USB drive will be successfully formatted based on the file system you specified and you will see your USB drive in the File manager with the new label.

Format USB Drive through the GParted tool

Gparted is an open-source utility in Linux systems that can be used to format the USB drives. Following is the procedure to install and use this tool:

Installation

1. Run the following command in Terminal to install Gparted utility:

$ sudo apt-get install GParted

Install GParted

The system might prompt with a Y/n option to continue the installation procedure. Hit Y and then Enter to continue after that the Gparted will be installed on your system.

Formatting USB Drive

2. Launch the Gparted utility by hitting the super key on your keyboard and searching it through the search bar. Then from the results, click on the Gparted utility to open it.

3. You will be required to enter the root password for authentication as only root user can run the Gparted utility. Enter the password and click the Authenticate button.

Become admin user using sudo

4. When the utility is launched, by default it will display the /dev/sda partition of the hard disk. To view the details of your USB drive, select it from the drop-down located at the top right corner a shown in the following screenshot.

GParted

Once you select the USB drive you will be able to see its details in the Gparted window.

5. Before formatting the USB drive, you will first need to unmount it. Under the Gparted utility, right-click the USB partition that you want to format and select Unmount option.

Unmount drive

5. Now your USB drive is ready to format. Right-click the USB partition under the Gpated utility and select Format to option. Under the Format to option, you will see several file system options. Select the file system type you want to use for your USB drive.

Choose filesystem type

You will see the added operation as pending operation at the bottom left of the Gparted utility.

6. Now to apply this operation, click the Apply button from the toolbar.

Apply changes

7. Now you will be asked to confirm the operation as all your data on the USB drive will be formatted. Once you are sure, click the Apply button.

Confirm format options

8. The formatting operation will be started and your USB drive will be formatted based on the file system you specified.

Formatting the drive

After the formatting process is finished, you will be notified as follows.

Operation successfully completed

Click the Close button to return to Gparted main window.

That is all there is to it! In this article, we have discussed both the GUI and the command-line ways to format a USB drive. Following either of the above-discussed methods, you can easily wipe off your USB device for better use.