SD card seems in read only mode and I cannot format it.

Solution 1:

I have found this problem annoyingly often with microSD cards. First check for the obvious (e.g. software permissions/ownership and write-protect switch on the adapter - remember the switch is low quality, try moving back and forth a bit) and trying the hdparm -r option (software can set the hardware into read-only mode; see the hdparm man page; Windows has a corresponding software method too). If it still is read-only the reason probably is that the card itself has put itself in read-only mode due to some internal error (Google: "go read-only if it has not enough working flash cells to write").

If it is this hardware problem than no software solution can override the card's internal controller; tools like fdisk, mkfs and so on might appear to do their job, but when you remove the card and put it in again the state was exactly as it was before! (By the way: it is best NOT to reformat SD cards - see the Wikipedia: https://en.wikipedia.org/wiki/SD_card#Risks_of_reformatting)

I have also heard that some card readers can think a microSD card is write-protected if it isn't properly positioned (something to do with write-protect tabs at the side) but I've tried my faulty cards in 3 readers, pushed in snugly, without success, although other cards write without problems.