I have a 64GB micro sdcard which was removed from an android phone without unmounting (could not find unmount after upgrade to android 7.1,they tried to make it easy and intuitive - it is an eject icon, 6 levels deep in the menu, so cannot be found by search for "unmount")
now the sdcard can be mounted and unmounted, data can be copied from it, but writing to it, deleting files or formatting it or writing new partition table is no longer possible; deleting files appears to work, but after unmount and mount again, everything is back to the way it was when it first started erroring out while copying files to the micro sdcard from linux; so writing to the card worked for a few mount/unmount cycles after taking the card out of the android phone without unmount;
trying to format it in the android phone errors out; in a camera, it says memory card locked; in ubuntu 18.04:
lsblk mmcblk1 179:24 0 59.5G 0 disk └─mmcblk1p1 179:25 0 59.5G 0 part
Create Partition Table
sudo gparted Input/output error during write on /dev/mmcblk1 sudo hdparm -I /dev/mmcblk1p1 /dev/mmcblk1p1: HDIO_DRIVE_CMD(identify) failed: Invalid argument sudo hdparm -I /dev/mmcblk1 /dev/mmcblk1: HDIO_DRIVE_CMD(identify) failed: Invalid argument sudo hdparm -v /dev/mmcblk1 /dev/mmcblk1: HDIO_DRIVE_CMD(identify) failed: Invalid argument readonly = 0 (off) readahead = 256 (on) geometry = 1949664/4/16, sectors = 124778496, start = 0 sudo hdparm -L 0 /dev/mmcblk1p1 /dev/mmcblk1p1: setting drive doorlock to 0 (off) HDIO_DRIVE_CMD(doorlock) failed: Invalid argument sudo gnome-disks Error while repairing filesystem on dev/mmcblk1p1 Process reported exit code 1: fsck.fat 4.1(2017-01-24) (udisks-error-quark, 0) sudo fsck /dev/mmcblk1p1 fsck from util-linux 2.31.1 fsck.fat 4.1 (2017-01-24) 0x41: Dirty bit is set. Fs was not properly unmounted and some data may be corrupt. 1) Remove dirty bit 2) No action ? 1 Perform changes ? (y/n) y
fsck does not error out, but running it again, everything is back as before.
sudo mkfs.vfat -n 64 /dev/mmcblk1p1 mkfs.fat 4.1 (2017-01-24)
format does not error out, but when mounting again, everything is back as before.
testdisk Disk /dev/mmcblk1 - 63 GB / 59 GiB - CHS 1949664 4 16 Current partition structure: Partition Start End Size in sectors 1 * FAT32 LBA 32 0 1 1949663 3 16 124776448 [64d] Warning: Bad starting sector (CHS and LBA don't match) sudo dd if=/dev/zero of=/dev/mmcblk1 bs=512 seek=1
stopped it by control-c after 4GB, still no changes, files are still there, cannot write to micro sdcard
Basically, it seems that formatting, gparted writing a new partition table, fsck clearing the dirty bit, even writing with dd, all have no effect. The micro sdcard is not physically damaged, mount/unmounts just fine, which is why I thought that formatting it, and if not, then using gparted to write a new partition table should totally clear it and make it like new again. What am I missing? Why can't I format it? Is there something else I can try? It is as if it has some settings in there which cannot be accessed by these tools; it is a transcend micro sdcard
edit: tried to format the micro sdcard on windows xp, it said the card is read-only; connected with a usb micro sdcard adapter which showed the card as 32GB, and then with a multicard reader (micro sdcard into sdcard adapter into reader, usb out of reader) which showed 60GB and read-only; the problem is not the adapter, as I inserted the card in a laptop with ubuntu 18.04 that has a micro sdcard slot, so no adapter, and also in an android phone, again, no adapter;
tried mkusb-dus, but it refuses to wipe or reset the card
tried dd to overwrite entire card, but after mounting it again, everything is still there; files can be copied but not deleted; cannot create partition table to reset sdcard
I read there is a read-only diskwide attribute I will try to see if I can reset that