Formatting usb pen in Linux

Q. How do I format USB pen in Linux?

A. You can use standard mke2fs command to format usb pen in Linux. mke2fs is used to create an ext2/ext3 filesystem (usually in a disk partition or other USB devices). device is the special file corresponding to the device (e.g /dev/hdXX). blocks-count is the number of blocks on the device. If omitted, mke2fs automagically figures the file system size. If called as mkfs.ext3 a journal is created as if the –j option was specified.

Step # 1: Verify or find out your usb partition name

Type the following command to find out USB pen partition name:

# fdisk -l

Step # 2: Format parition

Once identified the partition name type the following command to format the usb pen in Linux (caution you must select correct usb partition name, otherwise you will loss all the data on hard disk):

# mkfs.ext3 /dev/sda1

To format as VFAT/FAT32 file system type the command:

# mkfs.vfat /dev/sda1

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!

{ 3 comments… read them below or add one }

1 Mark Luxton 08.15.08 at 3:58 pm

I have been using Gparted to set up my USB pen.
I find it near impossible to make mistakes this way.
I had formatted it as FAT16 and it works going from Linux box to windows box and back. Eventually the pen would not allow me to add files even though there was over 3GB available. Could this be due to the deletion of files only removing the TOC and not the actual data?
I just reformatted as FAT32 to see if that works better. Files are copying now. Is there a preferred format? FAT 16 or 32 or Linux Ext2 or 3. I realize it must be FAT to go to a Windoze box(or NTFS if all you got is Windoze).
Note: At one point I could not get a large group of files to copy to the root of the pen drive but was able to do so into a folder on the drive???

2 Richard Steven Hack 10.13.08 at 9:48 pm

As for not being able to copy large number of files to a FAT16 root directy, I vaguely recall there is a limit to the number of files FAT16 supports in a root level directory. I think you can only a maximum of 512 files in a root directory because under the FAT16 system the root directory has a fixed size whereas subfolders do not.

3 Frank 02.08.09 at 11:35 pm

Hi guys,

I have been pondering similar thoughts. It is my understanding that FAT16 in LBA mode is limited to a partition size of 2GB. Although, it has been reported that up to a 4GB partition is supported but is known to cause issues.

Can anyone shine further light on the limitations of a FAT16 partition?

References:

Link #1 and Link 2

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>

Previous post: Howto find out or Learn harddisk size in Linux or UNIX

Next post: How do I start and stop NFS service?