Format usb flash drive from command line on linux/ubuntu

By | August 7, 2013

If there is a lot of content on the usb flash drive and you want to erase all of it quickly then a simple way to do it is by formatting it. On linux the drive can be formatted from the commandline.

Here are the simple steps

1. First insert the usb drive.
2. Once the system has detected it run the mount command from the terminal.

$ mount
/dev/sda5 on / type ext4 (rw,errors=remount-ro,user_xattr)
/dev/sdb1 on /media/E93D-1723 type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks)

Find out the device from the mount output. In this case it is /dev/sdb1

3. Next format it using the mkfs command

sudo umount /dev/sdb1
sudo mkfs -t vfat /dev/sdb1
sudo eject /dev/sdb1

First unmount it, then create filesystem/format using the mkfs command and then eject when done.

Can also use gparted so that you dont have to remember the commands.

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

One Comment

Format usb flash drive from command line on linux/ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *