Skip to main content
  1. Archives/

Formatting USB pen drive in Linux using Terminal

··251 words·2 mins·
Tips & How-To's Commands Filesystem Linux

Insert your USB pen drive. Let it get detected and mounted. Open Terminal. Type The Following commands

  1. dmesg |tail -> here the ‘|’ key is the pipe, ie, the key before the backspace key(the upper one, so press shift)

You’ll get something like

sathya@shaman:~$ dmesg |tail

[ 9921.681164] sda: Write Protect is off

[ 9921.681174] sda: Mode Sense: 23 00 00 00

[ 9921.681178] sda: assuming drive cache: write through

[ 9921.709138] SCSI device sda: 4030464 512-byte hdwr sectors (2064 MB)

[ 9921.720951] sda: Write Protect is off

[ 9921.720963] sda: Mode Sense: 23 00 00 00

[ 9921.720967] sda: assuming drive cache: write through

[ 9921.721225] sda:

[ 9921.727896] sd 0:0:0:0: Attached scsi removable disk sda

[ 9921.744187] sd 0:0:0:0: Attached scsi generic sg0 type 0

Note the terms in bold. In your system it will be different, maybe sdb or something. Whatever it may be, make sure to substitute it in the commands below, else your hard disk may get formatted.

  1. Unmount your pen drive by using

sudo umount /dev/sda (In your case, please substitute sda with the appropriate device, listed above.

  1. use the mkfs.vfat command to format to FAT32 filesystem, or mkfs.ext3 to format to ext3 filesystem

sudo mkfs.vfat -n ‘Label’ -I /dev/sda Replace Label with the name you want the pen drive to have.

  1. That’s it! When done formatting, you’ll be returned to the prompt

sathya@shaman:~$ mkfs.vfat -n ‘sathya’ -I /dev/sda

mkfs.vfat 2.11 (12 Mar 2005)

sathya@shaman:~$

Remove and insert the pen drive to have mounted again!

Sathyajith Bhat
Author
Sathyajith Bhat
Author, AWS Container Hero and DevOps Specialist.

Related

5 Commands Every Linux Newbie Must Know
··476 words·3 mins
Tips & How-To's Commands Tips Tutorials
Although Linux had progressed far from being a command-line only OS to a full fledged totally GUI based one, sometimes, the command line is the best way to get something done. Here are 5 of the must-know commands. These commands can b quite useful and handy. 1: mount: Used for mounting Windows/Other partitions, just in case it isn’t automatically mounted. Usage: mount here refers to the special device where your partitions are.
3i-Infotech, Here I come
··150 words·1 min
News
Well, I’d been to Bangalore to collect my offer letter for a job as Trainee Software Engineer at 3i-Infotech yesterday. Most of the people who had cleared the GD, seemed to have cleared the Personal Interview as well, atleast most of the people who were in my group. The joining formalities was headed by a HR person named, Anupama, and boy was she grouchy! Is she always so? Whatever it maybe, I’m glad she wasn’t the one taking my interview.
Howdy!
··85 words·1 min
News Hello World
Howdy folks. After my first attempt at blogging, which was “very successful”(thanks to me of course, I was too active, you know!) I’ve decided to start my blogging “career” all over again. Hope I will be more motivated than ever to maintain this, thanks to a certain “jobless” friend of mine, who kept pestering me about my nonexisting blog. If you’re still reading this, wow well and good! Hope to hear some “interesting” comments, brickbats and rants from ya all.