How to Fix a USB Drive Using Ubuntu

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

USB drives are handy devices when you're on-the-go, but these devices can get corrupted or damaged. Some errors are common, especially if you use Ubuntu and installed Linux to the USB using either the DD command or a Windows tool such as Win32 Disk Imager. Despite the drive being a certain size (for example, 16 gigabytes), you often only see one partition, which is smaller, or the Disk Utility and GParted show a message stating the block size is incorrect.

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

USB flash drive with laptop
bluehill75 / Getty Images

Don't be alarmed if the drive has some strange partitioning, or the block size is incorrectly reported when you open GParted. You might see errors when running the Disk Utility program within Ubuntu. The USB drive isn't broken; it's confused.

How to Install and Run GParted

GParted isn't installed in Ubuntu by default. You need to take care of that before you can proceed.

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

  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-get install gparted
  2. Press the super key or press the application launcher on the desktop to open the GNOME applications menu. Search for GParted and select the GParted icon when it appears.

    GParted on Linux
  3. Select the disk representing the USB drive from the menu in the upper-right corner of the screen.

    The hard drive menu

How to Create a Partition Table

Once GParted is installed, you should see a large area of unallocated space. If not, that's all right. Sometimes partitions get corrupted. This fix will work in that case too.

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

    The Device menu
  2. A window appears warning that all data will be erased. Leave the partition type as msdos.

    The msdos format
  3. Select Apply.

    The Apply button

How to Create a Partition

The final step toward fixing the USB drive is to create a new partition. Here's how:

  1. Right-click the unallocated space, then choose New from the menu.

    The New command
  2. The two key fields in the box that appears are File System and Label. If you only use the USB drive with Linux, leave the default file system as EXT4. If you also use it on Windows, change the file system to FAT32.

    The fat32 File system
  3. Enter a descriptive name in the Label field.

    The Label field
  4. Select Add.

    The Add button
  5. Select the green arrow or checkmark icon in the toolbar to apply the changes.

    The Apply All Operations button
  6. Another message appears asking whether you're sure you wish to continue as data will be lost. When you get to this point, any data that was on that drive is gone. Select Apply to finish.

    The Apply button

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

If you have access to a Windows computer, try it out to make sure it works correctly.

What to Do If the Above Steps Don't Work

If the above steps don't fix your USB drive, try the following:

  1. 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, select it.

  2. Enter the following command in the terminal, replacing /dev/sdb with the path to the problem drive:

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

    The command takes time to run, as it's a low-level format of the drive. It may take up to a few hours, depending on the size of the drive.

  3. When the dd command finishes, use the instructions above to create a new partition table and partition.