How to format USB pendrive in Ubuntu terminal. This tutorial explains how on Ubuntu, you can format USB fat32 via command line.
The first step to format pendrive in Ubuntu terminal is to identify the USB drive. To get the info about the USB, run the following command in terminal:
$ df -h
In the output of the above command, the last line in the output lists /dev/sdb1 is the USB drive.
Once you are aware of the USB drive name and mount point you can format the USB. Note that you can only format an unmounted USB drive. Otherwise, you will get the message “Make file system with mkfs command.”
To unmount the drive through the following command:
$ sudo umount /dev/sdb1
Once the command is executed, the USB drive will be successfully unmounted.
To format the USB, use one of the following commands as per the file system you want.
Many people prefer VFAT and NTFS file systems to format a USB drive because they can be easily used on the Windows operating system and Linux as well.
There are three popular USB file systems which are popularly used:
- File Allocation Table (FAT) was the default filesystem for MS-DOS and Windows 9x operating systems and it was (FAT) was replaced with NTFS as the default file system on Microsoft Windows XP operating systems and onwards. FAT is still popular and used on USB flash drives because of its compatibility and ease of implementation. FAT32 is the 32-bit version of the file allocation table (FAT) file system which specifies the protocol for storing and organizing data on a hard drive with file names and certain permissions.
- NTFS stands for New Technology File System. It was first used by Windows NT operating system (OS) for storing and retrieving files on hard disk drives (HDDs) and solid-state drives (SSDs). NTFS supports the Windows NT security model and supports multiple data streams.
- ext4 (fourth extended filesystem) is a journaling file system for Linux and under this file system, drives up to 16 TB can be connected. The ext4 filesystem can support volumes with sizes in theory up to 64 zebibyte (ZiB). One of the greatest feature of ext4 is – ext4 does not limit the number of subdirectories in a single directory. It is noteworthy to point out that in ext3 a directory can have at most 32,000 subdirectories.
To format a USB drive as per your desired file system, run the following command:
To format a USB drive with vFat File System
sudo mkfs.vfat /dev/sdc1
To format a USB drive with NTFS File System
sudo mkfs.ntfs /dev/sdc1
To format a USB drive with EXT4 File System
sudo mkfs.ext4 /dev/sdc1
That’s all. I hope you have learned to format a USB drive on a Linux system via the commandline.