How To Fix An Damaged Usb On Ubuntu
How To Fix An Damaged Usb On Ubuntu
Sometimes USB memory sticks just become unreadable, probably because we have remove it from the
port before unmount it or because we had to force to stop a process that was operating with it. In any
case, we would like to fix our USB to avoid loosing a valuable storage device.
Some OS, like Windows or MacOS X, seem to not react when USB is plugged. This is why I use GNU/Linux
to fix this issue.
Instructions
Before plugging the USB flash drive, check the devices in your system by using this command in
terminal:
lsblk
First level of hierarchy represents devices, and second level represents the partitions inside that device.
lsblk
There will be a new device on list. In my case, device was “sdb” and partition “sdb1”. In this post, I write
“sdX” and “sdX0” whenever I make reference to device and partition, respectively.
An alternative to lsblk command would be:
sudo fdisk -l
2. Delete USB
It takes time, be patient. For me, it took more than an hour for a 16 GB USB from a laptop from 2010.
When it finished, if I run a lsblk, I only see device “sdX” without any other partition. In some other
tutorials I have read, it considers there are partitions below “sdX” (like sdX1). This is not my case, so I
had to add the following step.
There are two main of partition table types, and both are covered in this post:
If you are looking for any other partition table type, you have to look further on other sources. They are
not covered on this post.
Perform only one of the following options, depending on whether you want MBR or GPT.
3.1. Create an MBR partition table
Remember to substitute the path with the one that applies to your device.
If partition table is not created, it will create a DOS disk label (msdos) without prompting.
In the command line from fdisk, confirm that you want to write changes by typing:
To create a GUID Partition Table (gpt) partition table, I use “parted” command instead of “fdisk”.
Then:
mklabel GPT
Warning: The existing disk label on /dev/sdX will be destroyed and all data on
Yes/No?
4. Create partition
In this step, we are creating the first partition for the gparted.
Type:
Remember to substitute the path with the one that applies to you.
Now you need to choose any of the following options, depending whether you had selected msdos or
gdp partition table.
4.1. Create partition on MBR partition table
Choose a partition number. You only need to create 1 partition, so enter 1, then press Enter.
When prompted to choose between creating a primary or extended partition, choose p for primary. This
step only applies for MBR partition tables.
Choose a partition number. You only need to create 1 partition, so enter 1, then press Enter.
Choose the start and end sector numbers. To use the whole drive, press the Enter key twice to keep the
default options.
Choose a partition number. You only need to create 1 partition, so enter 1, then press Enter.
Choose the start and end sector numbers. To use the whole drive, press the Enter key twice to keep the
default options.
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-30310366, default 30310366):
Sometimes after partition table is GPD, system asks whether you want to remove signature. As this is a
new partition and you are not resizing an existing one, you can accept to remove the signature.
5. Format partition
Format USB by typing the corresponding command in terminal. The command may vary depending on
the USB format you want to appy (FAT32, NTFS, ext4, etc.)
Check the list of different file systems if you want to check it.
Remember to substitute the path with the one that applies to you.
FAT
NTFS
Ext4
Remember to substitute the partition path with the one that applies to you, and <labelname> by the
label name you want to apply. Also remember to keep the two colons.