Formatting USB or Pen Drive in Linux Terminal (Using Command)

I am going to format my Sony External Memory Card

Card Name in My Linux System : /media/PHONE CARD

1. Login with root mode or switch to su
root@antony# sudo su
[sudo] password for anthoniraj:

2. Check the device name of the USB using fdisk or mount command
root@antony# mount
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
/sys on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,noexec,nosuid,nodev,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
devshm on /dev/shm type tmpfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
lrm on /lib/modules/2.6.22-14-generic/volatile type tmpfs (rw)
/dev/sda5 on /media/sda2 type ext3 (rw)
/dev/sda6 on /media/sda3 type ext3 (rw)
securityfs on /sys/kernel/security type securityfs (rw)
/dev/sdb1 on /media/PHONE type vfat (rw,nosuid,nodev,shortname=mixed,uid=1000,utf8,umask=077,usefree)
/dev/sdc1 on /media/PHONE CARD type vfat (rw,nosuid,nodev,shortname=mixed,uid=1000,utf8,umask=077,usefree)

(or)

root@antony# fdisk -l

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0fc10fc0

Device Boot Start End Blocks Id System
/dev/sda1 1 5106 41013913+ 83 Linux
/dev/sda2 5107 14593 76204327+ 5 Extended
/dev/sda5 5107 8753 29294496 83 Linux
/dev/sda6 8754 11303 20482843+ 83 Linux
/dev/sda7 14347 14593 1983996 82 Linux swap / Solaris
/dev/sda8 11304 14346 24442866 83 Linux

Partition table entries are not in disk order

Disk /dev/sdb: 27 MB, 27652096 bytes
2 heads, 6 sectors/track, 4500 cylinders
Units = cylinders of 12 * 512 = 6144 bytes
Disk identifier: 0×00000000

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 2018 12104+ 4 FAT16 <32m units =" cylinders" 512 =" 2097152" style="font-weight: bold;">/dev/sdc1 * 1 970 1986544 e W95 FAT16 (LBA)

The Last line of both commands is My Memory card device name i.e., /dev/sdc1

3. Unmount the USB drive using umount command
root@antony# umount /dev/sdc1

4. Format the drive using mkdosfs command
root@antony# mkdosfs -F 16 -n ‘Antony’ /dev/sdc1
mkdosfs 2.11 (12 Mar 2005)

Here
-F 16 is the option used for specifying FAT file system (FAT16)
-n is the drive lable

both are optional.If options are omitted, mkdosfs automatically determines the file system size

No Responses to “Formatting USB or Pen Drive in Linux Terminal (Using Command)”

  1. S says:

    Thank you very much. This article was extremely helpful.

  2. Jyoti Sharma says:

    Summarily:
    Look at the desktop icon that had popped up. Probably “Phone”
    type mount on command line
    Note the link to the device node corresponding to it, here /dev/sdc1
    type ‘sudo mkdosfs /dev/sdc1′ and enter the root password

    Is this right?
    Of course sudo should be configured before this to allow the current user to invoke mkdosfs. Else mkdosfs should be called in root shell.

    Regards

Leave a Response