How To Fix A USB Drive Using Ubuntu

Fix A USB Drive Using GParted
Fix A USB Drive Using GParted.

Introduction

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.

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, I will show you 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

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.

Step 1 - Install GParted

By default, GParted isn't installed in Ubuntu.

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

Step 2 - Run GParted

Press the super key to bring up the Dash and search for "GParted". When the icon appears, click on it.

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

Step 3 - Create A Partition Table

You should now see a large area of unallocated space.

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

A window will appear stating all data will be erased.

Leave the partition type as "msdos" and click "apply".

Step 4 - Create A Partition

The final step is to create a new partition.

Right click on the unallocated space and click "New".

The two key fields in the box that appears are "File System" and "Label".

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".

Enter a descriptive name into the label field.

Finally, click the green arrow icon in the toolbar to apply the changes.

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.

Click "Apply".

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, and 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

This will completely clear all data and all partitions from the USB drive.

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 a few hours)

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