[Quick Tip] Format USB Drive in Ubuntu, Linux Mint
A quick tutorial on how to format a USB drive in Ubuntu.
Formatting a USB stick, Or any other USB device is a tricky business in Linux. It should have been a simple task for most users but there are some very annoying errors that you may face during format operation in Ubuntu. Here are the steps you need to follow to properly format a USB drive.
Steps to format a USB Drive
- Plug-in the USB device. Wait for Ubuntu to auto mount the USB.
- Open file manager and right-click on the USB device.
- Click format.
- Choose either slow, quick format method based on your preference.
- If everything goes well for you, it should be formatted properly. If it is not, then you may get caught in below error.
This error happens because the program was trying to write wrong size blocks into the device.
At this point, Ubuntu in-built format under files is not sufficient to fix the USB. We need disk utility Gparted.
- Install GParted by running below command from terminal in Ubuntu.
sudo apt-get install gparted
- Once installed, launch GParted from dash. Make sure enter administrator password when asked.
- GParted should show the USB device as <code>/dev/sdb</code> or some other code as per your system. Once you have selected the USB drive, the entire partition table of your USB drive would be displayed.
- Select the partitions and delete them from the context menu. Once you have deleted all of them, click apply operations to write the changes to the USB.
- After all the operations are completed, you can see entire size of your USB is marked as unallocated.
- Now create a new partition table from menu option Device -> Create Partition Table. Select type “msdos” and click apply.
- Select the unallocated device and click New from context menu to create a new partition and then click Add.
- Once the new partition is created, format the partition in your desire file system.
If above method of formatting a USB is not working Or you have messed up the partition table of your USB, then follow below steps:
- Open terminal. Run below command, make sure to change “sdb1” as per your USB block device name before running the command.
sudo umount /dev/sdb1 sudo dd if=/dev/zero of=/dev/sdb1 bs=4MB
- Keep patience, above command would take a while. Then run below command to format in fat or ext4 filesystem.
sudo mkfs.vfat /dev/sdb1 Or, sudo mkfs.ext4 /dev/sdb1