Ubuntu / Linux news and application reviews.

Formating your USB memory pen / stick via command line is pretty easy. Once you know how to do it, that is.

Just follow these steps to quickly format your USB media in Linux:

1. Insert your usb memory pen / stick or whatever into the USB drive and immediately after that, open a terminal and paste this:
dmesg | tail

You should get an output of something like this:

andrei@andrei-desktop:~# dmesg | tail
[ 2143.440053] scsi 6:0:0:0: Direct-Access JetFlash TS1GJFV30 8.07 PQ: 0 ANSI: 2
[ 2143.464348] sd 6:0:0:0: Attached scsi generic sg3 type 0
[ 2143.466113] sd 6:0:0:0: [sdd] 2002942 512-byte logical blocks: (1.02 GB/977 MiB)
[ 2143.466607] sd 6:0:0:0: [sdd] Write Protect is off
[ 2143.466610] sd 6:0:0:0: [sdd] Mode Sense: 03 00 00 00
[ 2143.466612] sd 6:0:0:0: [sdd] Assuming drive cache: write through
[ 2143.468733] sd 6:0:0:0: [sdd] Assuming drive cache: write through
[ 2143.468737] sdd: sdd1
[ 2143.476393] sd 6:0:0:0: [sdd] Assuming drive cache: write through
[ 2143.476398] sd 6:0:0:0: [sdd] Attached SCSI removable disk


See the "sdd" between the brackets? That's your usb media you just inserted. Remember it (it may be different for you, obviously!)!

2. Unmount your USB drive using the following command:
sudo umount /dev/sdd

Where "sdd" is your media drive you had to remember at step 1.

3. Format the drive using the following commands:

a) Format to FAT:
sudo mkdosfs -n 'Label' -I /dev/sdd

You can also use the "-F 32" parameter to create a FAT32 partition.

b) Format to EXT3:
sudo mkfs.ext3 -n 'Label' -I /dev/sdd


For both:
Where Label is will be the name displayed for the USB media so you can set it to whatever you want; and sdd is your usb drive you had to remember at step 1.


If your are not friends with command line tools, you can use a GUI for this called Gnome Format.