USB formatting is the process of erasing all data from the disk and prepare it for use. Sometimes we are required to change the filesystem on our USB drive, In that case, we have to format the USB drive with the new filesystem type. Formatting a USB drive in Ubuntu using Terminal commands is much easier than formatting it in Windows systems.

Advertisement

This tutorial will help Ubuntu (Linux) users with the simple steps for format a USB flash drive using the command line.

Step 1 – Attach USB to System

Insert a USB drive into your system and identify your USB drive correctly. This is the step you need to take care, because you may format the wrong disk if not correctly identify your disk.

df -h 
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       28G    24G  2.3G  92% /
udev            1.4G   12K  1.4G   1% /dev
tmpfs           277M  1.2M  276M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none            1.4G   34M  1.4G   3% /run/shm
/dev/sdc1      14.8G  1.4G  13.4G  10% /media/tecadmin

Now, You can see that the USD drive is attached as /dev/sdc1 device. Which is mounted on /media/tecadmin.

Step 2 – Format USB Drive in Linux

Whenever we attach a USB drive in Ubuntu, it is automatically mounted to the system. We can not format any disk on Linux systems that are already mounted. So first un-mount /dev/sdc1 USB drive on your system.

sudo umount /dev/sdc1 

Now, Use one of the following commands as per the file system you want. To format a USB drive, most of the users prefer VFAT and NTFS file systems because they can be easily used on the Windows operating system.

  • Format with vFat File System
    sudo mkfs.vfat /dev/sdc1 
    
  • Format with NTFS File System
    sudo mkfs.ntfs /dev/sdc1 
    
  • Format with EXT4 File System
    sudo mkfs.ext4 /dev/sdc1 
    

Similarly, you can format a USB Flash drive with any required file system.

Conclusion

In this tutorial, you have learned to format a USB drive on a Linux system via the command-line interface.

Share.

60 Comments

  1. I have followed your directions to a T for Ext4 and now my laptop does not see the usb drive. I pulled it out and re-inserted… Nothing. I am running Netrunner which is a debian based KDE distro.

    • You simply just need to mount the drive again after unmounting and formatting. Use [sudo parted -l] to see if the disk appears. If it does appear, then mount the drive manually using [sudo mount /dev/sdb1 /any_mount_name]

  2. i mounted my usb like this: sudo mkfs.ext4 /dev/sdb
    mke2fs 1.45.5 (07-Jan-2020)
    /dev/sdb contains a ext4 file system
    created on Tue Dec 22 22:50:59 2020
    Proceed anyway? (y,N) y
    Creating filesystem with 7507968 4k blocks and 1880480 inodes
    Filesystem UUID: 5bdaa6f5-3266-47f7-8d75-8424e03a5baa
    Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    4096000

    Allocating group tables: done
    Writing inode tables: done
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done

    after this I typed this:

    sudo umount /dev/sdb
    when I type this it says: I am getting umount: /dev/sdb: not mounted.

    and When I type this: sudo mkfs.ntfs -f /dev/sdb

    I get this error
    /dev/sdb is entire device, not just one partition.

    • mke2fs Creates a file system, it does not mount the drive. You can use it on a drive in an unmounted state.

      Did df -h say the drive was mounted?

    • when I try this with bootable linux distroy on my usb, I get not such directory of file.
      I’m trying reformat a live ubuntu usb drive. gparted and the disk utility won’t let me do it.

  3. Please disregard my last comment about the partition table (in the MBR) not being changed – it is modified by this procedure, but the result can still be (eg) 1.3Gb available out of a 7.7Gb memory stick if you choose VFAT.

  4. Notice this is not changing the partition table. If the partition table isn’t they way you want it (e.g. partition is too small, wrong type) you may need to use fdisk, which isn’t intuitively obvious but at least is present is all linuxes.

  5. mine is still showing the ubuntu iso in my flash drive and my 8gb is showing 2gb i used same terminal procedure and used ntfs

  6. i just format my 16 gb pendrive rhrough this process and my pendrive becomes 712 kb , now pls help me out how can i recover my original pendrive memory

  7. Wow! It seems too easy to be true. It’s on this “Initialising device with zeroes” bit and it looks like it’s going to take a long time. I hope this works! I’m a newbie to ubuntu and am thoroughly enjoying it. Thanks for this

  8. Cesar Amaral on

    Now my device is not recognized by Windows, on on my Linux system. How can I change it back to its original state?

  9. I tried to format a 32gb usb stick in NTFS file system with this option, but after the format the flash drive is only 2gb, how can i change this back to it’s original size?

  10. sduo umount /dev/sdc1
    umount: /dev/adc1: not mounted

    sudo mkfs.vfat /dev/sdc1
    mkfs.vfat: unale to open /dev/sdc1: Device or resource busy

    How can it be busy if it’s not mounted and how do I fix this?

    • corriendodelohpacoh on

      Maybe a process has opened a file there and has not correctly deallocated the resource. You can check with lsof /dev/sdd1 (device name may change) and kill the culprit.

      • How is this complicated? Most de’s literally have gui or standalone software for burning images and formatting usb. The only thing is that they don’t look exactly the same as windows software, lol. Linux doesn’t need people with a double digit iq who can’t even look into application menu

      • Yeah!
        Simple is Windows, isn’t? That very friendly environment where to go every step you need another cryptic damned.dll.
        Try to use Windows to write some code.
        I bet that in less than one minute it will ask for another hellish.dll or something more awkward.

  11. Florian Kempenich on

    For quick operation, you can add the ‘-Q’ option, it will perform a quick-format.

    This will skip both zeroing of the volume and bad sector checking, none of which are needed for a drive in good health when erasing non-sensitive data 😉

  12. Takes some time to format, but it works.
    Im using this to format usb to then create live LLite 3.8 iso

    Thank you Rahul, its a great tip !

  13. Really useful and concise, thanks.
    Worked well in Linux Lite 3.6 32bit.
    It dealt with two drives that got wrecked in Windows 7 and that Windows 7 would then not format properly.

  14. Thanks, was looking for this. and I found out that with the -n option you can give a name to the drive, for instance:

    [root@athens mahler]# mkfs.vfat -n mahler /dev/sdc1

    And your key will be labeled “mahler”

  15. Hey thanks I used my quite overpowered 128GB flash drive to install my current linux distro. And it was seeing it as a 1.5GB file system. That I couldn’t write to. But your tutorial helped me out a lot as it’s a 124GB. I am guessing 4gb was used for the file system itself.

  16. This was great thanks, quick question; how to you format a flash drive if it was in 2 partitions and make it one again? I lost the small partition.

  17. I could not get Partitionmanager or GParted to work. This worked great, however. (I formatted a 3TB USB drive as ext4, for use as a backup drive)

  18. Your article is misnamed. It’s “Format USB in UBUNTU” . If your article is proprietary to Ubuntu, that is what you should call it.

Exit mobile version