This guide covers the step-by-step process of formatting a USB drive via the command line. We will give the commands to follow while showing an example for demonstration purposes. That way, you can conveniently follow along and format your USB drive.
Step-by-Step Guide to Format a USB on the Ubuntu Terminal
When using Ubuntu, you can quickly format your USB drive with straightforward steps that anyone can get comfortable using. Note that formatting your USB will erase all its contents. If you don’t want to lose any data, create a backup before you start the formatting. Also, ensure that you connected the USB drive to the ports on your computer, then proceed as follows.
First, we must locate where the USB drive is mounted on our Ubuntu. You can use the df command to print all the mounted file systems. Adding the -h option makes the command to print in a human-readable format.
In our case, the target USB drive is the /dev/sdb1 and is in the /media/kyle/k.
Alternatively, you can use the lsblk command and filter the output using the grep command to get the mounted USB drive.
Before we format the USB drive, we must unmount it since you can’t format any mounted disk on a Linux system.
To unmount the USB drive, use the umount command followed by the mounted USB drive.
Once you unmount the USB drive, verify the mounted file systems to verify that we now have the USB drive unmounted.
You are now ready to format your USB drive, depending on the file system that you want to use including FAT32, NTFS, etc.
For FAT32, use the following command:
For NTFS, use the following command:
Use the following command to use the EXT4 file system:
In our case, we format the USB drive as FAT32 to make it usable with any operating system.
Your USB drive is now formatted. We can verify it using the fsck command as presented in the following:
A formatted USB drive contains no files, like in the previous output, where our /dev/sdb1 displays that it has zero files which confirms that we managed to format it successfully.
You now have your USB drive formatted to use for your activities. If the drive is infected, formatting it cleans up all its clusters, and you now have a clean and usable USB drive.
When you want to format a USB drive on Ubuntu using your terminal, there are different steps that you must follow. First, locate the mounted file system for your USB drive. Next, unmount the USB drive file system and proceed to format it depending on the format file system in your case. Lastly, verify that your USB has been formatted.