Friday, July 23, 2010
8:04 PM

Formatting using the Linux Command Line.

If you do not have a format option in your Linux GUI don't worry. The command line is always there to help you.

 The command that you can use to format a pendrive or any other drive is "mkfs" .
The syntax is

mkfs [-V]  [-t fstype] [fs-options] filesys [blocks]

Where the -V option will produce a verbose output on your terminal.

The important part is the "-t" options with which you can specify what kind of filse system do you want to create using the command.
For e.g.  the windows follows filesystems "FAT" and "NTFS". Linux follows the filesystme "EXT3", "EXT4".
In case you want your drive to be recognized both in windows and Linux, it would be a good idea to use create a FAT filesystem. To create a FAT filesystem use the option VFAT with -t.

The "filesys" specifies the actual drive or the partition that you want to format. To get to know this you can use the command "sudo fdisk -l".  or "df -h"


Note: sudo option is not required if you have logged in as root.


From either of the command find out the /dev/sd The will differ from one system to another depending on what you wan to format.


For eg: This is the output of df -h



Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5              48G   33G   14G  71% /
none                  986M  340K  986M   1% /dev
none                  990M  480K  990M   1% /dev/shm
none                  990M   84K  990M   1% /var/run
none                  990M     0  990M   0% /var/lock
none                  990M     0  990M   0% /lib/init/rw
/dev/sdb1             1.9G  4.0K  1.9G   1% /media/New Volume

If you want to format a pendrive it will be mounted in /media. So in the above output what we want is format is /dev/sdb1. 

Thus the mkfs command would be 

mkfs -V -t vfat /dev/sdb1 


0 comments:

Post a Comment