Linux – Format a protected (corrupted) sd card

formatlinuxsd card

Some days ago one of my micro sd cards (a 32gb by Samsung) "decided" it is protected. It has no physical switch and I haven't found a way to format it yet. Every software I try to use says it is protected or read-only. I hoped GParted would have helped me but it didn't. I believe it's just a software problem hoping to find a solution. Any idea? Maybe some Linux command? Ah, the sd is current in ntfs file system.

Best Answer

I have a linux command for you: hdparm

Set the readonly flag, card will be readonly:

markus@markus-ThinkPad-W530:~$ sudo hdparm -r 1 /dev/mmcblk0

/dev/mmcblk0:
 setting readonly to 1 (on)
 readonly      =  1 (on)

Clear the readonly flag, card wil be read-write:

markus@markus-ThinkPad-W530:~$ sudo hdparm -r 0 /dev/mmcblk0

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

Query the readonly flag, 0 = readwrite, 1 = readonly:

markus@markus-ThinkPad-W530:~$ sudo hdparm -r /dev/mmcblk0

/dev/mmcblk0:
 readonly      =  0 (off)

Markus

Related Question