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

- 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!
No related posts.
Post comment
Archives
Recent Posts
- Installing Linux Mint 5 LTS into a Pen-Drive
- BlackBerry SSH: Connect to the remote Linux Server using MidpSSH on BlackBerry Curve 8520
- How to hack or crack Wi-Fi Password Using Debian Linux
- Cracking Wi-Fi Password with Debian Linux
- Speed Up Your Web Browsing with OpenDNS
Recent Comments
- janav on BlackBerry SSH: Connect to the remote Linux Server using MidpSSH on BlackBerry Curve 8520
- sandeep on Speed Up Your Web Browsing with OpenDNS
- Rakesh on BlackBerry SSH: Connect to the remote Linux Server using MidpSSH on BlackBerry Curve 8520
- Marc Paradise on BlackBerry SSH: Connect to the remote Linux Server using MidpSSH on BlackBerry Curve 8520
- Rakesh on CairoDock on Debian Lenny (like dock in Mac OS X)
Blog Sponsor
Tags
Switch site
Blogroll
- Debaira: Debian Blog
- Ian Murdock: Debian
- Linus Torvalds
- Mark Shuttleworth: Ubuntu
- Naba: Anjuta (IDE)
- TechCrunch


Posted by Rakesh in
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=adfcc24b-903d-4b58-98a9-2a5523c61783)

