Skip to content

KALI – How to format a USB pen in Linux


We can format a USB in ext3 (the linux format) or vfat (for both Windows and Linux) machines.

Step 1 – Find out the exact name of the USB


mount step 1mount will list out the /dev/sdxx listing for all drives.  We could also use:

ls /dev

To get a real-time view of the /var/log/messages file the command is

sudo tail -f /var/log/messages

You’ll see the device reported… press control + c to get the prompt back.

If it’s USB pen, it’s very likely the drive will be


It’s important to know that /dev/sdb is the entire device and /dev/sdb1 is the first partition on the device.


Step 2 – Unmount the USB

**notice the spelling.. it’s umount

 umount /dev/sdb1


Step 3 – Create a new Filesystem with FDISK

sudo umount /dev/sdb1

sudo fdisk /dev/sdb

The first thing to do is to exame the existing partition, we do this by entering P at the prompt.  Entering L will list out all possible file types, and T will change a partition’s system ID.  The Hex code for Linux is 83.

Up to this point, the device has not been touched, all the changes are stored in memory not the physical device.  To save, we write using W.  If you want to leave the device unaltered, enter q at the prompt to exit FDISK without writing the changes.  Ignore the “doom and gloom” warning messages.

Step 4 –  Create a new filesystem with MKFS – convert to a Linux ext3 filesystem.

mkfs means “make filesystem” on our flash drive.

sudo mkfs -t ext3 /dev/sdb1

convert to ext3 red arrows


This means “make a filesystem”, of “type ext 3” on “device” at “/sdb1”

Watch the Inodes and file system being created

writing ext3 to usb green tick on inodes


Step 5 – ReFormat the USB back to VFAT for Windows

To reformat the device to its original FAT32 filesystem, specify VFAT as the filesystem type.

sudo mkfs -t vfat /dev/sdb1

convert usb back to fat 32 - wordsVFAT allows both Linux and Windows to read/write to the USB.  However it has a 4 GB single file limit.. which might catch you out if you try to write say the CENTOS 6.5 DVD ISO to a USB…as the filesize is 4.3 GB.

Step 6 – Check the filesystem with FSCK

Fsck can repair corrupt filesystems.  Recovered portions of files are placed in the lost+found directory, in the root of each filesystem.

sudo fsck /dev/sdb1

check that fat32 exists - words 2


Admission – I was on the Backtrack Machine at the time… sorry – my bad!


Why is unmounting important?

In the output of the “free” command we see statistics including BUFFERS.  In order to make systems work as fast as possible, data is sent to buffers, the writing to the physical device is often deferred to a future time.  The data piles up in memory.  Occasionally the OS will write out this data to the physical device.  Unmounting a device allows all the remaining data to be written to the device so that it can be safely removed.  If the device is removed without being unmounted, some data maybe lost.  In some cases, this data may include vital directory updates, which will result in a filesystem corruption, which is one of the worst things that can happen.



University South Wales reading list.

SHOTTS, W.E., 2012.  The Linux Command Line.  San Francisco: No Starch Press.

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: