How to format a usb drive with FAT32 file system on Linux

Written by
Date: 2011-03-11 10:36:30 00:00


Introduction

For all Linux users, work with usb drives, is really easy, and share data with Windows users through it, is also easy.

At least before you need to format the usb drive for any reason, if you format it using Linux ext3 or any other Linux mode, you will not be able (at least not easily) to share data with Windows users. What you need is to format the usb drive using FAT32 file system.

Install dosfstools package

The package you need to install in your Linux PC to be able to format disk using FAT32 file system is: dosfstools

Install dosfstools in Debian / Ubuntu

 apt-get install dosfstools

Install dosfstools in Arch Linux

 pacman -Sy dosfstools

Install dosfstools in Slackware

 slackpkg install dosfstools

Format usb drive with FAT32

Now that you have the right tools installed, it is time to use it, so to format a usb drive using FAT32 first insert your usb drive in the usb slot of your computer, and check with

 fdisk -l

You will see something like this:

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 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: 0xed1f86f7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1135     9116856    7  HPFS/NTFS
/dev/sda2            1136        9141    64308195    5  Extended
Partition 2 does not end on cylinder boundary.
/dev/sda3            9142        9729     4717440   12  Compaq diagnostics
Partition 3 does not end on cylinder boundary.
/dev/sda5            1136        3047    15358108+  83  Linux
/dev/sda6            3048        3493     3580101    7  HPFS/NTFS
/dev/sda7            3494        8809    42700738+  83  Linux
/dev/sda8            8810        9141     2666758+  82  Linux swap

Disk /dev/sdc: 8075 MB, 8075120640 bytes
154 heads, 36 sectors/track, 2844 cylinders
Units = cylinders of 5544 * 512 = 2838528 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb0bcd68e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        2845     7884836   83  Linux

As you can see /dev/sdc is where my usb thumb drive was connected.

Now lets format it with:

     mkdosfs -F 32 -I /dev/sdc1

WARNING: Be really careful before formating a disk, you will not be able to recover your data, double check that you are applying the command to the right device before you hit ENTER

Note: You are supposed to have a partition created on the disk, before you format it.