Formatting a USB Drive on Linux

This is something I just don’t do often enough to remember all the steps. So here is a little reminder for how to format a USB drive.

  • Insert the drive into the USB port
  • Check the bottom of /var/log/messages to see which device it is. You’ll see a message that looks something like this:

Alternatively you can list /dev/disk/by-label:

…or with fdisk:

Here you can see my USB drive is sdd1.

In this case it is device sdd.

  • Format the device (in this case sdd) with fdisk:

    • use ‘p’ to print the current partition table
    • use ‘d’ to delete partition(s)
    • use ‘n’ to create a new primary partition (p)
    • use ‘p’ to print the new partition table

    It should look something like this:

    • use ‘w’ to write the new partition table
  • Create a new file system on the flash drive:

    In this example I use the vfat filesystem. You can choose other filesystems like ext2 or ext3. To get a list of filesystem available (maked in blue below) use:
  • Create a directory into which to mount the flash drive:
  • Mount the flash drive:

And that should do it.

Additional info:

To list the drives by uuid use

If you liked the post, please leave a comment or share/like it. Thanks! 🙂

7 thoughts on “Formatting a USB Drive on Linux

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.