Centos 6/RHEL format USB Drive Command

Like the Zip file/folder commands, I sometimes forget the USB drive format syntax, so I put it here as a reminder.

Often USB drives get clogged up with old files which hide themselves in trash folders not visible, causing phantom 'drive full' notices etc, and you just have to start afresh again and clear out everything at low level without any partitions.

To format a usb drive without partitioning it, first plug it in.

$ sudo su

# fdisk -l              to list disks

You can also use 

$ sudo cat /proc/partitions

But you will just get the device, ie 'sdc' not the path

[root@Centos anton]# fdisk -l

Disk /dev/sda: 320.1 GB, 320071851520 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e6735

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       38914   312056832   8e  Linux LVM

Disk /dev/sdb: 750.2 GB, 750152146432 bytes
255 heads, 63 sectors/track, 91200 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x404a6639

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       91200   732562976    c  W95 FAT32 (LBA)

Disk /dev/mapper/vg_centos-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_centos-lv_swap: 6392 MB, 6392119296 bytes
255 heads, 63 sectors/track, 777 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_centos-lv_home: 259.5 GB, 259463839744 bytes
255 heads, 63 sectors/track, 31544 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/sdc: 4043 MB, 4043309056 bytes
125 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 7750 * 512 = 3968000 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

I want to format the 4GB drive at the end, /dev/sdc

It needs to be unmounted if it's mounted

# umount /dev/sdc                            then format it  

# mkfs.vfat -I /dev/sdc

The 'I' flag is to access the whole drive

If it already has a partition like below skip the 'I' flag


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       91200   732562976    c  W95 FAT32 (LBA)

So you can format it with

# mkfs.vfat /dev/sdb1

It is usable cross platform in Linux and Windows

You can format to ext2 or ext3 if you want

# mkfs.ext3 /dev/sdc        (no 'I' flag, just a 'y' prompt)

Simple commands to quickly sort out a usb drive









           









Labels: , , ,