12

I have a MicroSD card in a USB adapter (which plugs into a USB port on my machine, and acts like a USB flash drive). I was using Unetbootin to make this a bootable USB flash drive with Kubuntu. But I needed to cancel while it was working. So I killed the Unetbootin process from the console.

Since then, I can't format the MicroSD or delete the folder that Kubuntu made. I have also tried mkdosfs, with no success. I can't mount the drive anymore either? What can I do to make this drive usable again?

Trying to create a new partition table in GParted, as described in Eliah Kagan's answer, does not work. It fails with the error message "imposible crear tabla de particiones" ("unable to create a partition table").

  • Have you tried erasing any existing partition information by using sudo dd if=/dev/zero as suggested in the answer from 'izx'? If the dd command is successful then I would recommend you create an MBR (msdos) partition table and a single FAT32 partition using gparted before retrying UNetbootin. (I have experienced problems trying to use multiple partitions on a USB drive. While you are just trying to get this to work it is probably best to start with a very simple setup.) – irrational John Jun 1 '12 at 20:34
  • try executing testisk for the device once connected. let it check and confirm if there are any issues. once scan is succesfull write the partition information. then you can use fdisk/gdisk to create partitions depending on MBR/GPT based partitions – v_sukt Jul 13 '17 at 7:48
20
+50

Analysis of the problem

Memory cards and USB pendrives have the same kind of hardware inside, so the same methods are relevant to both kinds of devices. The term 'drive' can refer to a USB pendrive as well as a memory card (and the memory card can be connected via a USB adapter or a built-in slot in the computer).

  1. Confusion: There is some data in the drive, that makes the partitioning tool confused, to think that the drive does not work. In this case you can simply 'wipe' part of the drive (overwrite with zeros). It is usually enough to wipe the first megabyte, the megabyte at the head end of the drive.

  2. The drive is read-only: I do not mean that there is a read-only file system, but that the drive is readable but not writable (like a CDROM or DVD). This might be caused by some help system or competing system, so it is worthwhile to try according to this list,

    • On some pendrives and on many memory cards there is a small mechanical switch for write protection, that can toggle between read/write and read-only. You might have set it read-only without intention.
    • Reboot the computer and try again to restore or wipe the first megabyte with mkusb.
    • Disconnect other USB devices. Sometimes USB devices can disturb the function for each other.
    • Try other USB ports, and/or other card adapters.
    • Try another computer.
    • Try another operating system (Windows, MacOS) in another computer.
    • If you still cannot wipe the first megabyte of the drive, and the drive is read-only, it is probably 'gridlocked', and the next stage is that it will be completely 'bricked'. There is a limit, when you have to accept that the pendrive is damaged beyond repair, at least with tools available to normal users like you and me. See this link: Pendrive lifetime
  3. The drive cannot be found: In order to use the tools for repair and partitioning, that are available to normal users like you and me, the drive must be recognized by the computer's system and listed for example by the command line tool lsusb or lspci. You get more details with the verbose option

    lsusb -v
    

    The drive must also be recognized as a mass storage device for example by the command line tool lsblk. The two command lines

    sudo lsblk -f
    sudo lsblk -m
    

    should list the drive in a way, so that you can identify it. The following command line is even better, because it lists also the model (which typically includes the brand name and/or model of a pendrive or a card adapter).

    sudo lsblk -o model,name,size,fstype,label,mountpoint
    

    (You can copy and paste from here to a terminal window in order to avoid typing errors.)

    Looking at a persistent live drive /dev/sdd and a cloned live-only drive /dev/sde can produce the following output,

    MODEL            NAME     SIZE FSTYPE  LABEL                     MOUNTPOINT
    ...
    Extreme          sdd     14,6G                                   
                     ├─sdd1   4,5G ntfs    usbdata                   /media/sudodus/usbdata
                     ├─sdd2     1M                                   
                     ├─sdd3   244M vfat    usbboot                   
                     ├─sdd4   874M iso9660 Lubuntu 16.04.1 LTS amd64 /media/sudodus/Lubuntu 16.04.1 LTS amd64
                     └─sdd5   9,1G ext4    casper-rw                 /media/sudodus/casper-rw
    Transcend 4GB    sde      3,8G iso9660 Lubuntu 16.04.1 LTS i386  
                     └─sde1   858M iso9660 Lubuntu 16.04.1 LTS i386  
    ...
    

    A memory card plugged into an internal slot may be recognized as /dev/mmcblk0 as illustrated by the following example, where an Intel NUC is booted from a microSD card in an adapter in the SD card slot,

    MODEL            NAME          SIZE FSTYPE LABEL MOUNTPOINT
                     mmcblk0      29.7G              
                     ├─mmcblk0p1   300M vfat   EFI   /boot/efi
                     ├─mmcblk0p2     1M              
                     ├─mmcblk0p3   6.5G ext4   root  /
                     └─mmcblk0p4   512M swap         [SWAP]
    

    In this case, no model name is listed. You can probably be convinced, that you are 'looking at' the card anyway, but there are other tools, that can help you identify the card, parted and lspci,

    sudo parted -ls
    Model: SD SP32G (sd/mmc)
    Disk /dev/mmcblk0: 31.9GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    Disk Flags: 
    
    Number  Start   End     Size    File system     Name  Flags
     1      1049kB  316MB   315MB   fat32                 boot, esp
     2      316MB   317MB   1049kB                        bios_grub
     3      317MB   7262MB  6946MB  ext2            root
     4      7262MB  7799MB  537MB   linux-swap(v1)
    
    lspci
    ...
    00:1e.6 SD Host controller: Intel Corporation Sunrise Point-LP Secure Digital IO Controller (rev 21)
    ...
    
    • Try according to the list in the previous paragraph, 'The drive is read-only: "On some pendrives ..."', if the drive is not found.
    • If the drive is found and recognized as a mass storage device, there is hope that you will succeed according to the next chapter.

Let us hope that there is 'only' confusion

Try to restore the drive to a standard storage device

Install and use mkusb (mkusb-dus), which can format alias restore a drive to a standard storage device (with an MSDOS partition table and a partition with the FAT32 file system). These instructions are relevant for many kinds of drives (USB pendrives, memory cards, hard disk drives, HDD, solid state drives, SSD), but probably most often used for USB pendrives and memory cards.

If you run standard Ubuntu, you may need an extra instruction to get the repository Universe. (Kubuntu, Lubuntu ... Xubuntu have the repository Universe activated automatically.)

sudo add-apt-repository universe  # only for standard Ubuntu

sudo add-apt-repository ppa:mkusb/ppa  # and press Enter
sudo apt-get update
sudo apt-get install mkusb mkusb-nox usb-pack-efi

See these links with more detailed instructions,

mkusb version 12 alias mkusb-dus: enter image description here

mkusb wipes the first megabyte as a first step of restoring it

Sometimes some data are 'tricking' the software to think that the drive does not work, even when it is good, and it is enough to wipe the first megabyte to get rid of those data. You may 'look at' the drive with a tool, that does not recognize or understand correctly the structure of the partition table or a system, for example

  • if it was cloned from an iso file, or
  • if there are traces from a RAID configuration on the drive.

So you can

  • let mkusb restore the drive to a standard storage device (a convenient standard solution), or
  • let mkusb wipe the first megabyte and after that use another tool, if you want another partition table and/or other file systems. gparted is a good tool, if you are running a graphical user interface (window manager or desktop environment).

What to do if mkusb fails

If mkusb fails, the drive is either not found by the system or read-only. In this case you should try according to the list in the paragraph 'The drive is read-only' (above).

  • 1
    Even at the "bricked" stage, where the pendrive is not even recognized as a device, you may be able to retrieve a working micro-SD card from it by disassembly. Sometimes it's the reading hardware that goes bad, not the memory itself. – ubfan1 Jul 7 '17 at 22:07
  • @ubfan1, please describe disassembly (maybe in an own answer, and add some links, if you have have any, that are useful in this context). And do you know a tool, that is available to normal users, or some useful command lines that will perform disassembly. Or do you mean mechanical or physical disassembly? In that case, how can you connect the memory to a computer afterwards? Is there some useful adapter (that is available to buy for normal users)? – sudodus Jul 8 '17 at 5:05
  • 1
    Yes, I meant a physical disassembly, pulling things apart, to see if the insides contain a micro SD card. This card, if one is found, may be read in any USB micro SD card reader (commonly available for less than $10), or even used in an adapter to the SD format (commonly comes with many micro SD cards when purchased) if the computer has SD card reading capabilities. – ubfan1 Jul 8 '17 at 5:39
  • Thanks @ubfan1, this is very useful information, I think particularly if a user wants to recover data from a bricked USB pendrive :-) – sudodus Jul 8 '17 at 5:45
  • 1
    One other thing I have found which if a pen drive etc is not recognized is that it is the crystal which has become disconnected and just needs to be soldered back on... sometimes you can harvest a good one from another USB device... – ben-Nabiy Derush Jul 13 '17 at 1:34
9

This is a bit late, but here's my input.

My brother somehow made his flash drive not work on Windows and read-only in Linux. Trying to use GParted to make a new partition table didn't work, so I tried the dd option. This didn't work either, but after a bit of fiddling I used the following command:

sudo dd if=/dev/zero of=/dev/sdb bs=1M count=40

After this I could use GParted again, and it worked perfectly. Obviously the first block was not the problem, but the problem lay somewhere between there and block 40.

  • You could do the same with the Disk Utility (I mean formatting that card and creating whatever partitions and file systems ) – user85164 Nov 5 '13 at 4:30
4

Unmount the usb drive first and then format it with GParted.

1

Install the gparted package in the Software Center (or in the Terminal/Konsole by running sudo apt-get update followed by sudo apt-get install gparted). This gives you the GParted Partition Editor.

Then run GParted. Find the MicroSD/USB drive in the list of devices in the drop-down menu at the upper-right corner of the screen. Make sure you have the right device. (You can look at its size to help gauge this.) It would be very bad if you accidentally formatted a different drive that had valuable data, or your Ubuntu system, on it!

With the correct device selected, run Device... > Create Partition Table.... Use the default options (i.e., just click Apply, don't change the option under Advanced). Please note that, while other modifications in GParted are only performed when you apply your changes, creating a new partition table wipes out anything on the drive on which it is done, and is performed immediately when you click Apply.

Now create a FAT32 partition on the device (or a FAT16 partition if it is very small, like just a few megabytes, or if you know you need a FAT16 partition, for example, because you are following directions that call for a FAT16 partition). The new FAT32 partition should cover the whole drive (which is the default in GParted). You'll see the partition there, but that's just showing you what it will look like when you apply your changes.

Then apply your changes (by clicking the green check mark). Quit GParted.

You should be able to find the new partition in any Nautilus (i.e., file browser) window, under Devices on the left. Mount the partition by clicking on it under Devices in Nautilus.

Now you should be able to write to it with UNetbootin.

  • 1
    thanks but i have already tried with gparted and nothing – Mauri Olivares Jun 1 '12 at 1:54
  • 1
    i tried (well i have 2 primary partitions in the usb of fat 32)i tried to delete,move,resise,formating to another format and nothing (at the both partitions) and the error it's always the same the tool is no avaible in this moment (or something like that i am translating from spanish by myself sorry) – Mauri Olivares Jun 1 '12 at 2:02
  • ok but i have already try do a partition table or "tabla de particiones" and the error is unable to create a partition table" or "imposible crear tabla de particiones" and just that and botton of "ok" – Mauri Olivares Jun 1 '12 at 2:06
  • @MauriOlivares Ah, I see. Sorry, I didn't realize the error message was in response to this. I've just edited that information into your question--that should help others to offer solutions to your problem (in case I don't come up with anything, or someone else has a solution for you first). – Eliah Kagan Jun 1 '12 at 2:09
0

I just tested it on my Linux, you should use Disk Utility. (System > Administration > Disk Utility)

  1. Click on unmount volume if it mounted. If an error arise, try to unmount it from the Desktop, if still an error arise, then remove it and plug it in again.
  2. Click on format drive and leave the default. (it is master boot record)
  3. After finishing deleting, click on Create partition and choose NTFS and leave the default.

This steps I tested myself, please if there is anything else, tell me.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.