Wednesday, January 7, 2009

Formatting USB pen drive in Linux using Terminal /shell


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
You’ll get something like

root@computer_world:~$ 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.

2. Unmount your pen drive by using
sudo umount /dev/sda (In your case, please substitute sda 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/sda 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
root@computer_world:~$ mkfs.vfat -n ’root’ -I /dev/sda
mkfs.vfat 2.11 (3 Jan 2009
root@computer_world:~$

Remove and insert the pen drive to have mounted again!

0 comments:

  © PC Template PC by PC 2008

Back to TOP