Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Filesystem»How To Format USB Drive in Linux Command Line

    How To Format USB Drive in Linux Command Line

    By RahulAugust 7, 20212 Mins Read

    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.

    flash drive format usb
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    A Beginner’s Guide to Formatting EXT4 Partitions on Linux

    A Beginner’s Guide to Formatting EXT4 Partitions on Linux

    Understand difference between Hard links and Soft links in Linux

    Difference between Soft Links and Hard Links

    ubuntu bootable usb

    How to Create Ubuntu Bootable USB in Windows 10/8

    View 60 Comments

    60 Comments

    1. Ron on April 3, 2021 3:17 am

      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.

      Reply
      • Ebagua on April 15, 2021 7:42 am

        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]

        Reply
    2. shashidhar on December 22, 2020 5:25 pm

      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.

      Reply
      • Paul C Allsopp on December 24, 2020 12:48 am

        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?

        Reply
      • chaz on December 24, 2020 8:20 pm

        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.

        Reply
    3. Mark on November 21, 2020 10:00 am

      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.

      Reply
    4. Mark on November 21, 2020 9:46 am

      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.

      Reply
    5. Norman on November 13, 2020 7:56 am

      Thank you.

      Reply
    6. xxx on November 5, 2020 6:15 am

      sudo mkfs.ntfs -f /dev/sdb1

      this works right and even fastest

      Reply
    7. joey on July 9, 2020 6:29 pm

      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

      Reply
    8. Rajeev on July 3, 2020 1:33 am

      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

      Reply
      • Rahul on July 3, 2020 5:34 am

        Hi Rajeev,

        What filesystem have you used to format usb ?

        Reply
      • Jksun on August 12, 2020 10:53 am

        Hey man, I follow your tuto. The size of my key is 653M now. I use FAT fs

        Reply
    9. valet on June 25, 2020 11:10 am

      great. it works!

      Reply
    10. ROland on May 30, 2020 8:05 pm

      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

      Reply
    11. Stephan on October 9, 2019 4:22 pm

      How could I format my SSD in NTFS before removing it from my old PC to use it in other PC?

      Reply
    12. Xunilresu19 on October 8, 2019 6:20 pm

      super! Many many thanks…!!!

      Reply
    13. Muhammad Usman on August 22, 2019 11:12 am

      Thanks! Much helpful

      Reply
    14. omar on June 27, 2019 10:24 am

      how to mount again ?

      Reply
      • thexowmilk on October 2, 2019 6:35 am

        mount /dev/sdX
        which X is the last letter of your USB

        Reply
    15. Cesar Amaral on June 21, 2019 2:41 am

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

      Reply
    16. Robin on May 5, 2019 8:28 am

      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?

      Reply
    17. Peter Fifer on May 1, 2019 5:36 am

      What will happen if you do not umount the drive and write over it with dd? Thanks

      Reply
    18. Haru on April 6, 2019 4:10 pm

      # Format fat32

      sudo umount /dev/xxx
      sudo apt install dosfstools
      sudo df -h
      sudo mkfs.vfat /dev/xxx

      Reply
    19. Ben on April 4, 2019 12:31 pm

      bash: mkfs.vfat: command not found

      Reply
      • Axel on May 12, 2019 8:52 pm

        You ARE root (sudo)?

        Reply
    20. Eric on March 21, 2019 2:25 pm

      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?

      Reply
      • corriendodelohpacoh on June 9, 2019 11:55 pm

        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.

        Reply
    21. yoda on March 16, 2019 11:37 pm

      can I partition a JFS ?

      Reply
    22. Linux on February 20, 2019 10:55 pm

      Easier than right click and format? NOT

      Reply
      • Stephen on June 19, 2019 2:25 pm

        Exactly. Perhaps if Linux didn’t make this so complicated, the system would be more popular.

        Reply
        • A human being on October 3, 2019 10:15 pm

          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

          Reply
        • Fernando on October 3, 2020 1:02 am

          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.

          Reply
    23. IMRAN KHALID on January 31, 2019 3:33 pm

      Can I use Ex-Fat formatted pendrive in linux?

      Reply
    24. Florian Kempenich on November 22, 2018 1:55 pm

      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 😉

      Reply
      • liz on December 15, 2018 4:06 am

        where do you add the -Q in the command line, before, after, in the middle. What should the command look like?

        Reply
        • Remigijus on April 4, 2019 7:12 pm

          Hi. Example:

          sudo mkfs.ntfs -Q /dev/sdc1

          Reply
    25. Aurelio on October 6, 2018 9:37 pm

      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 !

      Reply
    26. Osório on October 5, 2018 9:20 pm

      sudo mkfs.vfat -n VOLUME-NAME /dev/sdb1

      Reply
    27. Michael Gulikers on June 6, 2018 10:21 pm

      Thanks from a newbie

      Reply
    28. Tom on May 18, 2018 2:06 am

      I used this method to format a 500 GB hard Drive. It took a while but worked great. Thanks

      Reply
    29. duglass on March 18, 2018 7:24 am

      Hi dear RAHUL K

      very nic
      simple and complet

      thanks

      Reply
    30. Guechebar on February 18, 2018 11:12 am

      hello, it works really well. just follow instructions and don’t forget to start with umount command first.
      Tanks.

      Reply
    31. DaveJS on January 28, 2018 2:06 pm

      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.

      Reply
    32. BIKASHJIT on January 9, 2018 12:52 pm

      /Dev/sdb1 is mounted
      Then it says..

      Refusing to make a filesystem here !

      ??

      Reply
      • Rahul K. on January 10, 2018 3:37 am

        Hi Bikashjit,

        Please paste exact error here.

        Reply
      • Junk on January 27, 2018 6:37 pm

        Use this command: sudo umount /dev/sdb1
        This will unmount it so you can overwrite it.

        Reply
    33. Mahler on December 24, 2017 9:58 am

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

      [[email protected] mahler]# mkfs.vfat -n mahler /dev/sdc1

      And your key will be labeled “mahler”

      Reply
    34. Olivia on December 6, 2017 8:41 am

      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.

      Reply
    35. swapnil on July 25, 2017 7:36 pm

      its saying /dev/sdc1 file not found…

      Reply
      • Olivia on December 6, 2017 8:36 am

        Make sure instead of using what ever was in the tutorial use what ever the df -h gave you for example mine was sdb1

        Reply
    36. Sandeep Reddy on June 11, 2017 4:38 pm

      Awesome, Thanks for the info!

      Reply
    37. patrick on July 19, 2016 7:56 pm

      tks! it help me a lot! pretty simple and direct.

      Reply
    38. Warren on March 17, 2016 9:58 pm

      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.

      Reply
    39. Olle Gladso on February 17, 2016 4:18 pm

      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)

      Reply
    40. K Hill on January 21, 2016 12:24 am

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

      Reply
      • Key on May 29, 2016 4:51 pm

        All the commands listed in the article are common for all the Linux distros.

        Reply
      • Mahler on December 24, 2017 9:53 am

        I used these commands with Fedora and they worked just fine

        Reply
    41. Ashley on January 1, 2016 10:06 am

      nice description.thanks.

      Reply
    42. Anjali on October 13, 2015 4:41 am

      Thnks for the steps!!!
      Were of great help!!! 🙂

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.