Linux: Format Your USB Drive Via Command Line December 11, 2010Posted by Tournas Dimitrios in Linux.
Formatting your USB memory pen / stick via command line is pretty easy. Once you know how to do it, that is.
- 1) Insert your usb memory pen / stick or whatever into the USB drive (usually CentOs will auto-mount the device ) and immediately after that, open a terminal and one of these commands :
- lsusb (by default installed)
- less /var/log/messages |grep /dev/sd
- dmesg | tail
- dmesg | grep sd
lsscsi lists SCSI devices (or hosts) and their attributes . It is not a default utility on CentOs , thus it must installed separately (from epel repository) .
yum install lsscsi
- 2. Unmount your USB drive using the following command:
Where “sd[x]” is your media drive you had to remember at step 1.
USB drives (including USB keys ) appear on the SCSI bus. Typically, you’ll see them as “the next ” SCSI disk . So , if you already have an sda , the USB device will appear as sdb. The USB drive normally has a partition on it . To mount it , you must mount this partition .The numbering of partitions on USB drives works like the numbering of partitions on normal hard drives (from the Linux kernel perspective , there isn’t really a difference between these two different device types). So to mount the partition on a USB drive that has become available as /dev/sdb , you would typically use mount /dev/sdb1 /somewhere .
- 3. Format the drive using the following command:
- 4. Mount the drive again on your local filesystem :
mount /dev/sd[xx] /media/testmount