[Klug-general] Solution to media cards mounted read only

James Morris jwm.art.net at gmail.com
Sat Nov 19 13:13:36 UTC 2011


Hi,

I'm posting this in the event that someone finds it useful. It's one
of those problems that I've been working around for ages but finally
had enough of to locate a solution.

I've long thought it was my own fault that SD cards mount read-only,
that some aspect of system configuration was missing.

However, every so often, they do mount with write access but then time
passes and they don't. Again I assumed that system configuration had
changed after updates/distro change etc.

Today I found some claims that read-only mode in Linux is caused by
file system errors on the SD card. Apparently using the card in MS
Windows fixes the problem. But that's too inconvenient and not a
solution I want to use.

The cards I have are not old nor heavily used, so I tried mounting
them in turn and eventually found one which successfully mounted with
read/write mode.

Comparing kernel output via dmesg of the different cards revealed they
had different 'mode sense' values, which seemed to confirm what I read
about flags in the card's file systems which caused Linux to mount
them read only.

This brought me to the search terms 'sdhc "mode sense"' which yields
the solution* which doesn't involve MS Windows.

You need the hdparm utility installed, and also, to know the device
node. Basically you use hdparm to force Linux to re-read the partition
table of the card. For instance, on my system:

hdparm -z /dev/sdd



James

* http://forums.gentoo.org/viewtopic-p-6367579.html?sid=58a500f3e297c47e843871e6c67db21f#6367579

PS Some of these cards are min-sd's inserted into a micro-sd adapter.
The 16gb card had become unmountable in it, the 2gb card was mountable
read-only... I did hdparm -z /dev/sdd on the 2gb, and now have
read-write access on it, but also, on the 16gb too!?



More information about the Kent mailing list