How to format pendrive in Ubuntu using terminal? Commands to format pendrive in Linux Ubuntu command prompt. Unmount the USB drive before you begin to format it.
Find Device ID of USB Drive
Before you start formating the USB drive, you will need to know the device id of the USB drive. This drive id is used to format USB disk using terminal commands. To know the device id of the USB drive, run the command:
As you can see in the screenshot. The sdb3 is the device id of the USB drive.
Format USB Drive
Now unmount the USB device. Whenever any USB drive is attached to Ubuntu Linux system, it’s automatically mounted. While the USB device is mounted you cannot format it. So to format the USB drive, first unmount it using the following command:
sudo umount /dev/sdb3
Now format the USB drive. There are three filesystems options to format the USB drive.
Format USB with Extended File System (Ext) FileSystem
This is the most preferred filesystem from Linux Ubuntu Systems.
$ sudo mkfs.ext4 /dev/sdb3
Format USB with FAT (File Allocation Table) FileSystem
$ sudo mkfs.vfat /dev/sdb3
Format USB Format with NTFS (New Technology File System)
$ sudo mkfs.ntfs /dev/sdb3
Please note to change the USB device id in the above commands. I have used sdb3 which is device id of my USB drive.