How to repair a USB stick

Generally the main problem with USB memories is that the partition table may be corrupted or may be formatted with some non-standard file system. In short, it happened to all of us that after madly formatting a pendrive, it stopped being recognized by Windows or a DVD player. Well, here is the solution to this problem.

Repair USB sticks with GParted

The most comfortable way to repair a memory is with GParted.

To install it in Ubuntu, it would be:

sudo apt-get install gparted

Once installed, I opened gparted. Then I opened the Gparted> Devices> / dev / sdb menu. Select the drive in question, right click> Unmount.

All that remains to do is delete the current partition, create a FAT32 partition, and apply the changes.

In case of error, I accessed the Advanced Options in the same error window and select Create a partition table of type msdos. Then I repeated the process.

Once the partition is created, it must be formatted in FAT32. Finally, apply the changes.

Repair USB sticks with Fdisk

We've all had problems with USB sticks (they mysteriously stop working, don't mount well, etc). This happens because normally the partition table is not correct. This is the solution to solve it by Fdisk.

To detect the name of the usb device:

sudo fdisk-l

Then to repair the memory:

fdisk NAME

where NAME is the device name (ex: / Dev / sdb)

Choose o -> Clear partition table.
Choose n -> Create a partition.
Choose p -> This partition will be the primary one.
Choose 1 -> Make it the first partition.

It will ask you for the size, if you want the partition to occupy everything, set them to the default values.

Choose t -> I chose the type of partition format.
Choose c -> For FAT32.
Choose w -> For the data to be written to the USB.

Finally, format the partition created as FAT32:

mkfs.vfat -F 32 NAME

where NAME is the name of the partition (ex: / dev / sdb1).

As a lesson, it seems important to note that, following the example, / Dev / sdb is the device name and / dev / sdb1 is the name of the first partition within that device, which in our case is also the only partition. If there had been more partitions on that device they would be numbered sdb2, sdb3, etc. This same logic is repeated for all your devices and partitions in Linux.

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Ricardo Ricardo Rodriguez said

    I don't usually comment on blogs or pages but I want to thank you. My problem was that I wanted to make a USB bootable with USB image writer, which my current linux distro comes by default. When I was recording an iso (from a linux distro that I wanted to test) my laptop turned off and when I turned it on the USB memory did not work well, I could not format it or delete files from the distro that I was recording on it, I was trying to do the second method that you proposed on this page and I did not get results, even though I think I did everything right, then I decided to install Gparted and after some maneuvers, even in which I had several errors, even Gparted crashed the first time in the middle of the process. But I was finally able to fix it, thank you very much!

    1.    Alberto said

      Nothing really needs to be installed. When creating a usb-imagewriter image or even with unetbootin. happens that creates several partitions in them.

      All distributions have something like an application called Disks or partitioning in KDE is in YAST.

      In Gnome in applications you look for the Disks option. Once the usb is mounted, you select it and format it in ntfs format. If you get an error, you remove it and enter it again.

      Only the first partition is the one you are going to format to ntfs. Then you erase the partition and recreate it in FAT format or format.

      In Gnome on your left there is a button with several squares that takes you to the applications.

  2.   Juan Sánchez Larrauri said

    Hi. I have a problem. I am trying to recover a USB memory, I am not interested in the content but to start it up. Ubuntu does not recognize it. I have installed Gparted but although it recognizes it, it does not format it. And the console the answer that returns me is:

    dd opening <>: Permission denied

    So I have no idea how to go about repairing my USB anymore.

  3.   George said

    excellent post, I'm a linux user and I was able to repair 100% my USB memory.

    1.    Allan said

      Test as root by prepending sudo to the command

  4.   emmanuel said

    Thanks for the carnal cool data thousand thanks

  5.   Destroyer said

    Another method could be:
    we open a terminal and:
    mount (and we see which is our device)
    umount / dev / name of our device
    mkfs.vfat / dev / name of our device
    Everything that was in our unit will be "erased" (not exactly) and our unit will already be functional again as long as the failure was in its logical and not physical structure.

  6.   Victor R. Morales Chaves said

    Very good post, I will keep it in mind if I need it

  7.   Manuel R. said

    It is exactly what I was looking for, I knew how to do something similar in Windows, but being able to do it now from Debian is much more comfortable for me. Thank you very much for the information, greetings.

  8.   Miguel said

    Hello I hope you can help me, what happens is that when I put my microSD with my adapter it does not recognize it and in windows it appears that I must format it, I need to fix it but first I must recover the information that is in it since it is very important

  9.   August3 said

    I have a pendrive that does not boot. The grub menu recognizes it but does not start the OS recorded on the usb

  10.   Gin said

    Thank you very much and I was desperate that my usb did not work, but with this it has been like new 🙂

  11.   emersonleon said

    Thank you!!!

  12.   Frames said

    Good evening, if I do the operations with fdisk, can I recover the info that I had on the usb? thanks

  13.   Diego said

    Very useful for me, thank you!

    1.    let's use linux said

      Glad to hear it was helpful.
      A hug! Paul.

  14.   Facundo said

    Thank you very much, you saved my life !!
    I thought I had lost my pendrive, I wanted to install mac os maverick on my netbook and when formatting it instead of 16 gb it was 4 and the rest was unformatted (the crappy windows could not do anything)
    Sell ​​be ubuntu!

    1.    let's use linux said

      Hallelujah, brother!
      Welcome to Linux.
      A hug! Paul.

  15.   vic. vega. said

    it works perfect !! .. very well explained. thanks brother.

    1.    let's use linux said

      I am happy that is was useful for you!
      A hug! Paul.

  16.   Ruben said

    Excellent post. It worked perfectly with my two USBs that I thought were dead.

    Thank you!

  17.   Lucas said

    I have a problem I think bigger, I took out the pen while I was copying because it crashed and after that it was slow and I tried to do everything I finally got files with names like foreign symbols, when I try to format it it stays dead, I tried with Erase Disk and reaches 100Mb and the speed drops to 0 B / s, any solution? Or do I buy another one directly?

    1.    layco said

      You have not tried gparted, as described in the post? I have been rescuing usb with this method, as they say in previous comments: as long as the damage is not physical, everything has a solution.

      1.    lucas said

        Yes, it won't let me create the table, it throws a write / read error

  18.   regino said

    Thanks for this Post, one of the microSd cards that had damaged worked

  19.   alfonsog7 said

    go jewel, go well!
    They have a lot of old items. It would be good to try some and see what they work and WHAT DOES NOT WORK?

    This particular article served me well.
    regards

  20.   Yo said

    Thank you very much, it worked perfect for me !!

  21.   JAA said

    Although the post is old I had to thank you. I no longer knew what to do with that usb, gparted gave me an error after creating a new partition, from the terminal it tried to format directly and a new error.
    I said thank you very much.

  22.   Danilinho said

    Thanks a lot. It has worked perfect with the GParted application.

  23.   rabt said

    the title of this article would be to format USB memory ...

  24.   StokedAxis said

    It worked perfect for the first one, then I put it on the 2ds and he went back to fucking, he did the procedure again and he no longer let me: c

  25.   Aurelio said

    Thank you !!!!! Thanks a lot !!!

  26.   EEMB said

    How can I correct read and write errors on my memory card, please. Help ???

  27.   Custom USB said

    Thank you very much for the information. We work with USB sticks and we have tested it with a few that we had damaged and it has worked perfect.

  28.   Dante Alighieri said

    How do I format an SD that has only read permissions? I tried:

    unmount / dev / sdb1

    mkfs -F 32 / dev / sdb1

    mkfs.fat 3.0.27 (2014-11-12)
    mkfs.fat: unable to open / dev / sdb1: Read-only file system

    Anyone know a solution for this? Thank you

  29.   jesus said

    You saved my skewer, thank you very much, people like you improve this world, thank you again Jesus

  30.   Network Technology said

    Will it also be used for SD memories? I am trying to format an SD card and could not do it with anything.
    Greetings.

    1.    Luigys toro said

      It should work without problems

  31.   perez said

    it gives me an error that says
    NOTICE: Rereading the partition table failed with error 5 Input / output error
    The kernel still uses the old table. The new table will be used in
    next reboot or after partprobe (8) or kprartx (8) starts

    ATTENTION: If you have created or modified any of the
    DOS 6.x partitions, see fdisk man page
    to view additional information.

    Error closing the file

  32.   Juan said

    Hello, I don't usually comment but this was useful, thank you very much, applause

  33.   simon said

    I just did all this straw from the registry, to get hold of you, everything was great and as always, what I can't get windows if I get it on my cso kali linux thanks teacher

  34.   Federico said

    THANK YOU, you saved my pendrive.

  35.   Juan Luis said

    I had almost evicted my 30GB memory stick, and these steps worked out very well. Bravisimo for Linux, and its bloggers.

  36.   rober said

    very good, I have years of experience in linux. but never flirt with such problem. he knew very well how to use gparted and fdisk, also cfdisk. but it turns out that none of these packages work for me for now, not even testdisk. I try to delete the partition table and replace it with a new one in the mbr, but unfortunately it cannot be written. when I try to rescue, it always shows me to be a 64MB pendrive, when in fact it is 16GB. I conclude that it is a problem in geometry. Any solution that works by force?

  37.   Applejack said

    Thank you very much, I was starting to shit on a lot of things because my pendrive would not let me format, but thanks to you I ended up loosening the damn thing. Greetings and again, thank you very much.

  38.   mariouhhutjj said

    Very complicated, all that process is very easy to use DOS AND FLY the partition with fdisk and create the boot from 0

  39.   filter-external-aquarium said

    Excellent contribution! I add it to my favorites list because you never know when it might be necessary! You can tell that it was a magical solution for many.

  40.   forgetful said

    Hello,
    By formatting for gparted, the part of the firmware of the usb that identifies it as a usb memory was erased.
    That had never happened to me.
    It took a long time to write, and froze. After this, the pc detects that something was connected to the USB, but not what.

    There is a manufacturer's program that is supposed to fix it, but it doesn't recognize the device.

    what can be done?
    I suppose that you can copy the information from another memory as well.
    But how do I find out your address if you don't show it with lsusb, nor lshw,

  41.   Alan Echabarri said

    Hello, thank you very much, the gparted thing worked for me. Inadvertently I had formatted in ex4 and the usb did not recognize me, and thanks to your guide now ubuntu recognizes the usb memory. Salu2