Sunday, August 8, 2010

How to Format a USB Pen-Drive or a USB Flash-Drive in Red Hat Linux

Connect your pen drive to the system running Linux and let it get detected and mounted. Now open a Terminal, and type a command:

#dmesg | tail

Make sure that you have Root priviledges or you login as root to run the above mentioned command or the commands mentioned below:

The command (#dmesg | tail) lets you know what form of drive letters have Linux assingned to your pendrive. Remember pendrive is detected as a sata device so it starts with letter “sd” in Linux. Consider the output of following command at terminal:

sdb: assuming drive cache: write through
SCSI device sdb: 1994752 512-byte hdwr sectors (1021 MB)
sdb: Write Protect is off
sdb: Mode Sense: 23 00 00 00
sdb: assuming drive cache: write through
sdb:sdb1
sd 2:0:0:0: Attached scsi removable disk sdb
sd 2:0:0:0: Attached scsi generic sg1 type 0
usb-storage: devices scan complete


Note the output that have been shown in bold. The 'sdb' is the extension that Linux has assingned to your pen drive. “b” is the unique character that Linux has assingned to sata drive. The above term 'sdb' may differ in your system so make sure you replace the command below with the appropriate term as occur in your system.

Unmount your pendrive using the following command:

# umount /dev/sdb1 (Replace sdb as appropriate)

mkfs i.e make filesystem is the command used to format the pendrive here. so use mkfs.vfat to make a fat file system for your pendrive or mkfs.ext3 to make a Linux filesystem. Use the following command:

#mkfs.vfat -n ‘Label’ -I /dev/sdb1 (Replace sdb as appropriate)

Here Label is the word you want to assign to your pendrive so choose as suites you.

Once processing is done you are done and your pen drive is formatted.

No comments:

Post a Comment