Formatting USB pen drive/ flash drive in Linux from commandline/ Terminal

Posted Posted by Rakesh in Research     Comments No comments
Oct
9
Shaun's Work Bag
Image by Shaun Dewberry via Flickr

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

rakesh@debian:~$ dmesg |tail
sd 4:0:0:0: [sdb] Mode Sense: 23 00 00 00
sd 4:0:0:0: [sdb] Assuming drive cache: write through
sd 4:0:0:0: [sdb] 7856128 512-byte hardware sectors (4022 MB)
sd 4:0:0:0: [sdb] Write Protect is off
sd 4:0:0:0: [sdb] Mode Sense: 23 00 00 00
sd 4:0:0:0: [sdb] Assuming drive cache: write through
sdb:
sd 4:0:0:0: [sdb] Attached SCSI removable disk
sd 4:0:0:0: Attached scsi generic sg1 type 0
SELinux: initialized (dev sdb, type vfat), uses genfs_contexts
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.

2. Unmount your pen drive by using
sudo umount /dev/sdb (In your case, please substitute sdb with the appropriate device, listed above.

3. 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/sdb Replace Label with the name you want the pen drive to have.

4. That’s it! When done formatting, you’ll be returned to the prompt
rakesh@debian:~$ mkfs.vfat -n ’rakesh’ -I /dev/sdb
mkfs.vfat 3.0.0 (28 Sep 2008)

rakesh@debian:~$

Remove and insert the pen drive to have mounted again!

Enjoy Linux!

Reblog this post [with Zemanta]

No related posts.

Post comment

Archives

Recent Posts

Recent Comments

Blog Sponsor



Tags

Switch site

Blogroll


whos among us