Ubuntu Linux format USB pen drive

Q. How do I format a USB pen drive under Ubuntu Linux for ext3 file system?
A. You can format USB pen drive with the help of following commands:

[a] fdisk : Partition table manipulator for Linux

[b] mkfs.ext3 : Create an ext2/ext3 filesystem by formatting given partition name (/dev/partition)

[c] e2label : Change the label on an ext2/ext3 filesystem

First make sure USB pen is not mounted. Click on Places > Computer > Select USB pen > Right click > Select Unmount Volume.

Let us assume that /dev/sda1 is your partition name for USB pen. To format type the following command (Open X terminal and type the command)
$ sudo mkfs.ext3 /dev/sda1
Caution: Careful while entering device/partition name; wrong name can wipe out entire hard disk!!!
Now use e2label command to change the filesystem label on the ext3 filesystem located on device /dev/sda1:
$ sudo e2label /dev/sda1 usb-pen
You can also create an MS-DOS/Windows XP file system under Linux, enter:
$ sudo mkfs.vfat /dev/sda1

Now you are ready to use USB pen.

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 26 comments… read them below or add one }

1 Surja Gain 12.12.07 at 2:00 am

This guide was simple and effective. I have a Kingston 2 Gb pen drive. When I transferred some files into it from Ubuntu, the pen drive stopped working normally in Windows. When I right clicked it’s icon in windows, instead of ‘Open’ in the context menu, it showed some garbled characters. I could not format it in windows. Following the instructions given above I was able to format it to FAT32 and use it again normally.

2 Axl 12.21.07 at 5:01 am

Dear Mr. Gain,

With regard to your posting, I wish to bring to you notice that nobody the phaque cares what you do with your pen drive. The problems you have stated are bound to happen since the hardware/software that you are using are totally jali as you yourself. If in future, if such a problem arises, I would give you a plain and simple solution and that is, you can take your pen drive and shove it up…you know know where…sideways.

With regards,
Axl

3 Ed 12.24.07 at 10:19 pm

Axl:
The problem you demonstrate is called narcissism. I have known at least two persons with your symptoms. Unfortunately, psychiatric help for this condition is very rare.

Sorry,

Ed

4 Terrell Prude' Jr. 01.02.08 at 9:12 pm

Hey, come on, be nice folks. Mr. Gain brought up a valid point. I do use VFAT on USB sticks for the exact purpose of going back and forth between my GNU/Linux box and MS Windows. What Mr. Gain shared above is actually yet more evidence that our favorite platform (GNU/Linux) is superior to the offerings from Microsoft. GNU/Linux made that USB stick of his *truly* interoperable, not the farce that Microsoft pretends to promise.

–TP

5 JD 06.20.08 at 9:14 pm

Vivek,

Thanks for the great Q&A. It helped me to format my USB drive to ext3 quickly and without problems.

-JD

6 buckaroo 08.03.08 at 9:55 pm

I have a solution more easy:
Just install gparted from synaptic.

Is easy, simple and you can format and partition in all formats.
You can format pendrive, zip, diskette, disk, etc.

Buckaroo from Argentina.

Viva Ubuntu!!

7 Jiks 10.27.08 at 12:43 am

Hi,

I loved the article, excellent read. But I have a question. Not sure if this can be asked here: Can we have something done so that in the right click contextual menu of the USB pen drive another option appears, so that clicking on it can format the drive .. to the selected file system? :) ..

Sorry i am new to Linux and I find it hard to do the command line stuff.

I am not exactly sure even what to search for?

Regards,
Newbie to Linux :(
Jiks

8 Going quickly for Vista... 12.20.08 at 11:59 am

Question 1:
how do i find this device name /dev/sda1.
the only thing i found is something like /media/KINGSTON that doesn’t work.

Question 2:
i have spent already 20 minutes trying to do something that takes around 3 seconds to do in win XP (right click, format)…

9 Mephisto 12.20.08 at 7:37 pm

Dear Going quickly for Vista…
To see the right path just type in terminal “mount” with the pen drive mounted and you will see the path to format it. Then unmount it, and format it.

Hope this work to you like it work to me.
Happy Holidays to everyone!!!!

10 Going less quickly for Vista... 12.20.08 at 11:37 pm

Mephisto,
Before your reply I went to menu: system monitor-file systems and saw the name of the drive.

Thanks anyway,

Merry Christmas and a happy new year!

11 Diabolic Preacher 12.22.08 at 2:35 pm

hi vivek,
how do you specifically format a usb drive to fat 32 or to fat16. my observations.
1. fat16 wastes a lot of space but upto 2gb pen drives that’s been the standard, i’m assuming.

2. i formatted my usb drive as fat32 for the time being from a windows XP machine. since I’d had this pen drive since long and just wondered why i hadn’t got it to fat32 earlier. On linux, as you wrote in your post, there is vfat but how do we know whether it will select fat16 or fat32?

3. the reason i feel that vfat might format with fat16 is since that is something i saw from a latest DamnSmallLinux distro, which on going thru the steps to create a bootable DSL usb, formatted the data partition as FAT16. I thought it would atleast support FAT32 in a time where other distros are supporting NTFS read/write.

Thanks for the article.

12 Vivek Gite 12.22.08 at 3:46 pm

@Diabolic Preacher,

Use the -F FAT-size option

Specifies the type of file allocation tables used (12, 16 or 32 bit). If nothing is specified, mkdosfs will automatically select between 12, 16 and 32 bit, whatever fits better for the file system size. In short for fat32 do:

mkfs.vfat -F 32 /dev/sda1

13 Diabolic Preacher 12.22.08 at 4:13 pm

Hey Vivek,
I just went thru http://linux.die.net/man/8/mkfs.vfat and figured out the answer and came here to add a comment with the answer to help others know…and thankfully you’d already explained with code example.

N.B fat32 needs atleast 2 reserved sectors. any details on what this is?

14 Diabolic Preacher 12.22.08 at 6:09 pm

One thing I read in the man page is that 32 bit is never automatically selected. Its the only option that you have to explicitly specify. do you think this must be an old version of the man page?

mkdosfs will automatically select between 12 and 16 bit, whatever fits better for the filesystem size. 32 bit FAT (FAT32 format) must (still) be selected explicitly if you want it. from the mkdosfs/mkfs.vfat man page.

15 Vivek Gite 12.24.08 at 7:55 am

No I’ve same man page. Use -F 32 option as described above. Following may provide more info about FAT32
http://en.wikipedia.org/wiki/File_Allocation_Table#FAT32

16 aj 03.07.09 at 11:55 am

The above mentioned steps worked with me.
Thnks.

17 Sureshkumar 03.18.09 at 8:06 am

HI Vivek Gite ,

Superba ……….. it’s working nice

18 Howard 03.28.09 at 5:55 pm

Your information about usb formating is great. I have to say that it gets my goat when people post terrible comments about beginners asking questions that others take for granted. I began computing in 1987. I learned everything on my own and have chased Windows through each distribution. I work in simulation and our device has over 250 computers with almost all running Linux. It was time for me to change. I prefer to use command line when possible but that is not the norm. The average person wants a GUI and simplicity. Linux is almost there and gets better each day. For all you gurus out there, remember, there was a time when you needed help also. There will always be new users needing help and finding simple answers is not always easy. Offer them help or point them in the right direction, if not, don’t post.

19 Yet another lab admin 04.11.09 at 2:14 pm

Hi Vivek Gite,

I am an admin of a Lab with Ubuntu on all comps and would like to provide the users a means to format their pen drives. As the aforementioned method uses sudo, i cant use it in the lab. Any suggestions?

20 Vivek Gite 04.11.09 at 3:13 pm

Why not?

21 Yet another lab admin 04.11.09 at 3:15 pm

Well, the users dont have root access. So they wont be able to use sudo mkfs.vfat…

22 vandit 04.13.09 at 7:06 pm

thats what I dont get… why the need kept to sudo everytime we want to tinker with some filesystem. I mean why to build it that way when you can have normal users needing to do something like formatting or even mounting their devices.
ORĀ am I mistaken somewhere ??
can we specify such permissions for explicitly for users (like modifying certain folders , device contents etc.)

23 steve 04.19.09 at 7:32 am

Thanks for useful help. Now use Jaunty and this latest version is a real improvement. Gparted is a superb program and easy to use. Thanks for help.

24 Karri 04.30.09 at 8:26 am

To find what device you should format you can enter the command “mount”. It should show somethiong like

mount

/dev/sdf1 on /media/KINGSTON type vfat

To format the USB pen with the right name you can use

mkfs.vfat /dev/sdf1 -n KINGSTON

25 claudio 05.05.09 at 2:00 pm

Tks ! This tuto hepl me.

26 Darshana 06.10.09 at 6:38 am

Hey guys im in a big prblem! I got a verbatim pendrive. It had a pre installed Software on it which allowed me to split my pen into different partitions and make it password protected. Well i did that and then I got 3 MB as notpassword protected space. My pendrive is no longer functioning properly, and now when i try the properties, I get only 3 MB displayed.. How do i go from here?

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , , , , , , , , , , ,

Previous post: Howto install thunderbird-2.0.0.0.tar.gz in Linux

Next post: Howto: Linux convert an image between different formats from command prompt