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.
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.
60 Comments
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]
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.
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.
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.
Thank you.
sudo mkfs.ntfs -f /dev/sdb1
this works right and even fastest
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
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
Hi Rajeev,
What filesystem have you used to format usb ?
Hey man, I follow your tuto. The size of my key is 653M now. I use FAT fs
great. it works!
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
How could I format my SSD in NTFS before removing it from my old PC to use it in other PC?
super! Many many thanks…!!!
Thanks! Much helpful
how to mount again ?
mount /dev/sdX
which X is the last letter of your USB
Now my device is not recognized by Windows, on on my Linux system. How can I change it back to its original state?
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?
What will happen if you do not umount the drive and write over it with dd? Thanks
# Format fat32
sudo umount /dev/xxx
sudo apt install dosfstools
sudo df -h
sudo mkfs.vfat /dev/xxx
bash: mkfs.vfat: command not found
You ARE root (sudo)?
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?
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.
can I partition a JFS ?
Easier than right click and format? NOT
Exactly. Perhaps if Linux didn’t make this so complicated, the system would be more popular.
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.
Can I use Ex-Fat formatted pendrive in linux?
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 😉
where do you add the -Q in the command line, before, after, in the middle. What should the command look like?
Hi. Example:
sudo mkfs.ntfs -Q /dev/sdc1
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 !
sudo mkfs.vfat -n VOLUME-NAME /dev/sdb1
Thanks from a newbie
I used this method to format a 500 GB hard Drive. It took a while but worked great. Thanks
Hi dear RAHUL K
very nic
simple and complet
thanks
hello, it works really well. just follow instructions and don’t forget to start with umount command first.
Tanks.
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.
/Dev/sdb1 is mounted
Then it says..
Refusing to make a filesystem here !
??
Hi Bikashjit,
Please paste exact error here.
Use this command: sudo umount /dev/sdb1
This will unmount it so you can overwrite it.
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”
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.
its saying /dev/sdc1 file not found…
Make sure instead of using what ever was in the tutorial use what ever the df -h gave you for example mine was sdb1
Awesome, Thanks for the info!
tks! it help me a lot! pretty simple and direct.
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.
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)
Your article is misnamed. It’s “Format USB in UBUNTU” . If your article is proprietary to Ubuntu, that is what you should call it.
All the commands listed in the article are common for all the Linux distros.
I used these commands with Fedora and they worked just fine
nice description.thanks.
Thnks for the steps!!!
Were of great help!!! 🙂