A µSD card that was in a security camera suddenly stopped recording:
- Much of the data is gone (not a problem).
- The data that is still there is correct and readable.
- The card now always mounts as read-only, (on Chromebook, Windows, and Ubuntu).
I can't reformat it or do much of anything with it:
$ df
/dev/mmcblk0 vfat 117G 15G 102G 13% /media/ray/xxx
$ sudo fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 116.1 GiB, 124657860608 bytes, 243472384 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
$ sudo fsck /dev/mmcblk0
fsck from util-linux 2.34
fsck.fat 4.1 (2017-01-24)
open: Read-only file system
$ sudo hdparm -r0 /dev/mmcblk0
/dev/mmcblk0:
setting readonly to 0 (off)
readonly = 1 (on)
$ sudo hdparm -r0 /dev/mmcblk0
/dev/mmcblk0:
setting readonly to 0 (off)
readonly = 1 (on)
$ sudo fsck /dev/mmcblk0
fsck from util-linux 2.34
fsck.fat 4.1 (2017-01-24)
open: Read-only file system
$ sudo umount /media/ray/xxx
$ sudo mount -o rw /dev/mmcblk0 /media/ray/xxx
mount: /media/ray/xxx: WARNING: device write-protected, mounted read-only.
Note that this is not a full-sized SD card; there is no physical write-protection switch.
Is the card salvageable, or garbage?
Your SDcard has reached end of life. It will always be read only from now on. This is a protective mechanism when the controller detects the SDcard is not safe to try to write any more data to the card, Due to checksums mismatch. It does this to preserve your existing data. This is permanent.
You need to buy a new SDcard.
From this Source
I'm not sure that what has been answered here is entirely accurate. There's a lot more functions than can be done on an SD card than what can be done through the file system and block device interface, especially the security operations. The SD Association (the club that you must join to access the specifications and use the SD logo) has a tool called "SD memory card formatter" and that can be used (with most SD card slots) to give commands to the SD card that are not part of the normal block device interface.
I used to work in embedded electronics and I've rescued many locked SD cards with the SD formatter tool. It's available at https://www.sdcard.org/downloads/formatter/
Given the cost of a new card, trying to override the EOL lockdown seems like a bad idea. Reusing this card will risk further data loss.
The card went read-only and this allows you to rescue whatever was on the card at the time, which is a great design feature. I had a 16 GB card in a Pi, and I was able to
dd
the dead card to a new card, which booted up fine after anfsck
and the host continued on working.Additionally, a tool like
photorec
can scan the disk and potentially read some deleted files too. However video files tend to be large and that decreases the chance of recovery.Other options might be for you to consider a better way of dealing with this video data. Perhaps stream it off to a NAS or DVR/NVR where it is written to a hard drive? I have network cameras that are read continuously by
motion
which detects movement via inter-frame differences and saves video where changes are detected.Depending on the brand of camera, you may have further options about shifting content out of the camera.
Perhaps this camera is solar and has no network, so local storage is your best option. In that case, buy the largest card you can afford so there are more blocks total, and also look at the "industrial" cards which are rated for more resiliency. A "pMLC" card is Pseudo MLC and only uses the top and bottom two cells in a quad cell block, which adds resiliency at the cost of space, and cost.