Canot format MicroSD. File system is read-only

fdiskfilesystemspartitioningunixusb-flash-drive

I formatted it for my special needs some time ago using fdisk.
Don't remember the partition table, but there was 1 fat32 and 1 ext4 partition.
Now I want to format it fat32 clean, but I get the errors.

When I open GParted, it says

/dev/sdb contains GPT signatures, indicating that it has a GPT table. However, it does not have a valid fake msdos partition table, as it should. Perhaps it was corrupted — possibly by a program that doesn't understand GPT partition tables. Or perhaps you deleted the GPT table, and are now using an msdos partition table. Is this a GPT partition table?

If I click yes – it shows partitions, but creating new partition table fails, as it is read-only.
If I click no – it does not show up in the device list.

Here's a picture of the structure of the device.
enter image description here

What also strange, I remember making 1 GiB ext4, and rest fat32. But it shows the opposite.

So I tried formatting it with fdisk

# fdisk /dev/sdb
o
n
w
fdisk: cannot write disk label: Bad file descriptor

I made sure they are unmounted

umount: /dev/sdb1: not mounted
umount: /dev/sdb2: not mounted

Then I checked the filesystems. The second one appears to be read-only

# fsck /dev/sdb1
fsck from util-linux 2.23.2
fsck.fat 3.0.22 (2013-07-19)
/dev/sdb1: 18 files, 96978/698280 clusters


# fsck /dev/sdb2
fsck from util-linux 2.23.2
e2fsck 1.42.8 (20-Jun-2013)
fsck.ext4: Read-only file system while trying to open /dev/sdb2
Disk write-protected; use the -n option to do a read-only
check of the device.

# fsck -n /dev/sdb2
fsck from util-linux 2.23.2
e2fsck 1.42.8 (20-Jun-2013)
/dev/sdb2: clean, 860/65664 files, 56633/262144 blocks

Tried the zero trick, but failed as well.

# dd if=/dev/zero of=/dev/sdb
dd: failed to open ‘/dev/sdb’: Read-only file system

# dd if=/dev/zero of=/dev/sdb2
dd: failed to open ‘/dev/sdb2’: Read-only file system

Tried to disable the write-protection

# hdparm -r0 /dev/sdb

/dev/sdb:
setting readonly to 0 (off)
readonly      =  0 (off)

After that, fdisk still fails to format.

In Windows 8, it mounts only the fat32 part.
diskpart can't erase partition table as well.
diskpart output is translated from Russian, so it might not read well.

> diskpart
> select disk 1
> clean
diskpart encoundered an error: input-output error on the device

> convert mbr
This drive can't be converted. Ones that can't be converted are CD and DVD disks.

Best Answer

Finally I found the solution

MicroSD adapter has a "lock" feature. When I inserted the adapter, the lock always triggered to locked state. So I fixed it in unlocked state using the ducktape.

http://kb.sandisk.com/app/answers/detail/a_id/1102/~/memory-card-is-write-protected-or-locked

Related Question