Micro SD Overlapped to "Locked" and "read-only state" - How to fix it?

0

I have a Micro SD card (/dev/sdb) that is "Locked" in some "read-only" state. When I try to format it with Gparted or other graphical software it reports "Can't have overlapping partitions". Looking over the internet and on this site I found a possible solution using the comands:

sudo fdisk -l -u /dev/sdb
sudo sfdisk -d /dev/sdb > sdb-backup.txt

Then change the .txt file for a valid one fixing the overlapping partitions and apply the command:

sudo sfdisk /dev/sdb < sdb-backup.txt

After trying this I had no success in fixing my Micro SD Card. Here are the results: 1st First attempt to fix Micro SD Card:

sudo fdisk -l -u /dev/sdb
Disk /dev/sdb: 7,4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1          16 13546943 13546928  6,5G 83 Linux
/dev/sdb3       24897    24897        0    0B  0 Empty


sudo sfdisk /dev/sdb < sdb-backup.txt
Checking that no-one is using this disk right now ... OK

Disk /dev/sdb: 7,4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Old situation:

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1          16 13546943 13546928  6,5G 83 Linux
/dev/sdb3       24897    24897        0    0B  0 Empty

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0x00000000.
Created a new partition 1 of type 'Linux' and of size 12,2 MiB.
/dev/sdb2: Created a new partition 3 of type 'Empty' and of size 512 B.
/dev/sdb4: 
New situation:

Device     Boot Start   End Sectors  Size Id Type
/dev/sdb1          16 24896   24881 12,2M 83 Linux
/dev/sdb3       24897 24897       1  512B  0 Empty

The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
Syncing disks.

=> As I had no success in fixing the Micro SD Card, then I tried a second attempt. 2st Second attempt to fix Micro SD Card:

sudo fdisk -l -u /dev/sdb
Disk /dev/sdb: 7,4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1          16 13546943 13546928  6,5G 83 Linux
/dev/sdb3       24897    24897        0    0B  0 Empty

sudo sfdisk /dev/sdb < sdb-backup.txt
Checking that no-one is using this disk right now ... OK

Disk /dev/sdb: 7,4 GiB, 7948206080 bytes, 15523840 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Old situation:

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdb1          16 13546943 13546928  6,5G 83 Linux
/dev/sdb3       24897    24897        0    0B  0 Empty

>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0x00000000.
Created a new partition 1 of type 'Linux' and of size 6,5 GiB.
/dev/sdb2: Created a new partition 3 of type 'Linux' and of size 965,3 MiB.
/dev/sdb4: 
New situation:

Device     Boot    Start      End  Sectors   Size Id Type
/dev/sdb1             16 13546943 13546928   6,5G 83 Linux
/dev/sdb3       13546945 15523839  1976895 965,3M 83 Linux

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

=> I had no success again.

Questions: I would like to know: Is there still anything else using FDISK or other tool (graphical or command lined) I can try to recover my SD Card or I must consider it is destroyed and buy another one?

PS1: Maybe I have set some command wrong, so if you find it and can help me I thank you. Thanks for your time in reading and answering me.

PS2: I don't know if here is the correct space for it, but in response to the user who suggested the post What can I do if my USB flash drive is write-protected or read-only? to solve my situation, although the post is very well explained to a similar situation of read-only, it doesn't contain the solution to my problem with my MicroSDCard. I want to explain that my SD card is a MicroSD and does not contain a external pin to block its write state. I'm not tecnical in computing to prove it doesn't contain the answer to my situation, but after reading the above post I haven't found any way or solution to continue to solve my problem. If you want to help me just ask what more info you need about my MicroSDcard or comand line info that I post for those interested on helping.

===================== PS3: SOLUTION TO MY PROBLEM =====================

Well until now (January, 4th, 2017), THERE IS NO Solution to fix my MicroSD card. I tried to use the suggestions that bwDraco and AFH posted, but I had no success on restore my MicroSD functionality.

What about my MicroSD card problem and solution? Well I will wait a little more to see if someone else suggests here a different solution. I can still work on it's recovery if other people have anything more to suggest as a recovery option of its functionality.

Anyway I will consider to buy another SD Card. As bwDraco said, [possibly],"the card's broken. Memory cards fail like this alarmingly often, but at least replacements aren't expensive." "Stuff fails from time to time and it isn't necessarily your fault."

Fortunately, I had no important data on the MicroSD before this damage, so I didn't lose anything important on it. Anyway, is a bad thing to lose a storage device, I don't like it, but at least it's only a MicroSD loss, it doesn't represents a huge loss.

Besides that I'd like to thanks everyone who tried to help!

================================================================

sd-card
read-only
micro-sd-card
asked on Super User Jan 4, 2017 by Dan • edited Mar 20, 2017 by Community

1 Answer

0

From one of your comments (edited for formatting):

After applying sudo dd if=/dev/zero of=/sdb bs=64M code you suggested and the terminal worked for a while it showed me the response:

dd: error writing '/sdb': No space left on device
453+0 records in
452+0 records out
30384529408 bytes (30 GB, 28 GiB) copied, 278,123 s, 109 MB/s

What should I do now?

That should have been of=/dev/sdb, not of=/sdb. This command fills up the system disk, which could crash the machine. Run sudo rm /sdb to delete the extraneous file. If this fails, you may need to boot into a live CD to delete the file from your system drive. See this Ask Ubuntu question for more information on how to deal with a full root filesystem.


Once you've deleted the extraneous file, reboot to your original Linux system and try running the following command:

sudo dd if=/dev/zero of=/dev/sdb bs=64M count=16

If this fails with something like Input/output error, the card is bad and needs to be replaced. Otherwise, you should be able to reformat the card and use it normally.

answered on Super User Jan 4, 2017 by bwDraco • edited Apr 13, 2017 by Community

User contributions licensed under CC BY-SA 3.0