How to Format USB Device or Pendrive in Linux-Based OS Using commandline in terminal?

Formatting USB devices or Pen-drives in Linux-based operating systems using command-line is easy and straightforward. But you have to be cautious while using the Terminal, because a simple mistake can format your entire hard drive instead of your pen-drive.
Follow the steps below to format your USB device/pen-drive in Linux-based OSs:

  • Plug in your pen-drive or USB device. Now you have to have the path name of your pen-drive. For this open Terminal, and execute the following command:

dmesg

  • From here, you can see the device path name is sdc1.
  • In an alternative way, you can use the following command in Terminal:

sudo fdisk -l

This result also gave me somewhat the same result. I mean, here also I got the same device name; that is sdc1. You can use any of these command and have to remember the path name. In my case, as you saw, it was sdc1. In your case, it does not necessarily be sdc1. Your device maybe in sdb1 or in another path. Whatever it maybe, just remember it and execute it, as it is.

  • Now we got the device path name. Your device is already mounted. Before formatting pen-drive or USB device, you have to unmount that device. So, unmount your device with the following command in Terminal:

sudo umount /dev/sdc1

  • Here, in the aforementioned command, the main command is umount, not unmount. So DO NOT make any mistake. And replace sdc1 in the aforementioned command with your device name.
  • Now use the following command to format your device in FAT32 file format.

sudo mkfs.vfat /dev/sdc1

If you want to foormat your device in Ext4 format, replace mkfs.vfat with mkfs.ext4. That’d do.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s