How To Fix A USB Drive Using Ubuntu

Use a free graphical tool to erase and reset your USB drive

Close-up of woman connecting usb stick to laptop

 Westend61 / Getty Images

The title for this guide is "How To Fix A USB Drive Using Ubuntu". This suggests that the USB drive is in some way broken.

This fix used in this guide re-formats your USB drive, erasing any existing data. Before you go any further, be aware that by following this guide, any files on the USB drive will be lost.

The thing is that whilst the drive may have some strange partitioning going on or the block size is reported incorrectly when you open GParted or you get strange errors when running the Disk Utility within Ubuntu the USB drive isn't really broken. It is just a little bit confused.

In this guide, you'll learn how to get a USB drive into a state where you can access it again from GParted or the Ubuntu Disk Utility without getting errors.

The Errors

USB flash drive with laptop
bluehill75 / Getty Images

Common errors that you will get on a USB drive, especially if you have installed Linux to it using either the DD command or a Windows tool such as Win32 Disk Imager are that despite being a certain size (e.g.16 gigabytes) drive you can only see one partition which is much smaller or the Disk Utility and GParted show a message stating that you have an incorrect block size.

The following steps will help to fix your USB drive.

Install and Run GParted

By default, GParted isn't installed in Ubuntu. You're going to need to install it before you can get started.

  1. You can install GParted in a number of ways, but the easiest is to run the following command in the Linux terminal:

    sudo apt install gparted
  2. Press the super key or press the application launcher on your desktop to bring up the GNOME applications menu, and search for "GParted". Select the GParted icon when it appears.

    GParted on Linux
  3. Select the disk that represents your drive from the list in the top right corner of the screen.

    GParted select drive

Create A Partition Table

You should now see a large area of unallocated space. If not, that's alright too. Sometimes partitions get corrupted, and this fix will work in that case too.

  1. To create a partition table select the Device menu and then Create Partition Table.

  2. A window will appear stating all data will be erased.

  3. Leave the partition type as "msdos," and press Apply.

    GParted create new partition table

Create A Partition

The final step is to create a new partition

  1. Right click on the unallocated space, and choose New from the menu.

    GParted select unallocated space
  2. The two key fields in the box that appears are File System and Label.

    GParted create partition

    If you are only ever going to use the USB drive with Linux then you can leave the default file system as EXT4, but if you plan to use it on Windows as well, then change the file system to FAT32.

  3. Enter a descriptive name into the label field.

  4. Press Add.

  5. Finally, press the green arrow or check mark icon in the toolbar to apply the changes.

    GParted apply operations
  6. Another message will appear asking whether you are sure you wish to continue as data will be lost. Of course, by the time you get to this point any data that used to be on that drive is well and truly gone.

    GParted confirm apply operations

Press Apply to finish.

Summary

Your USB drive should now appear in the Ubuntu Launcher and you should be able to load files onto it again.

If you have access to a Windows computer it is worth trying it out to make sure it works correctly.

Troubleshooting

If the above steps don't work do the following:

Open a terminal window by pressing CTRL+ALT+T at the same time. Alternatively, press the super key on the keyboard (Windows key) and search for "TERM" in the Ubuntu Dash search box. When the icon appears, click on it.

In the terminal enter the following command:

dd if=/dev/zero of=/dev/sdb bs=2048

The command will take quite some time to run as it is a low-level format of the drive. Depending on the size of the drive it may take up to a few hours.

When the dd command has finished repeat steps 2 to 4.