I have microSD card which doesn't have read-only switch (but the adapter does).

I would like to switch microSD card into read-only mode (without adapter), so inserting it into any device like smartphone or Android TV box will prevent from writing (e.g., creating /Android or /DCIM folders) or formatting it. I could not find any physical switch on it.

enter image description here

  • 1
    \$\begingroup\$ Why didn't you enforce RO on a file system level \$\endgroup\$
    – Voltage Spike
    Commented Jun 24 at 13:51
  • 3
    \$\begingroup\$ @VoltageSpike Would it protect from formatting? You have such option in android to reformat the card: Settings > Storage > SD Card. \$\endgroup\$
    – ADM-IT
    Commented Jun 24 at 18:20
  • \$\begingroup\$ Nope, it would not, is this in a device you're building? \$\endgroup\$
    – Voltage Spike
    Commented Jun 24 at 20:03
  • \$\begingroup\$ nope, I just wanna use my sd card in a read only way on various available devices. The only solution I found so far is this learn.microsoft.com/en-us/windows-server/administration/…, but again, it does not prevent from formatting. \$\endgroup\$
    – ADM-IT
    Commented Jun 27 at 14:42

2 Answers 2


Short answer, you can't.

There are no readonly switches on MicroSD cards.

And the switch does not do anything to the card, the card does not know the setting of the readonly switch. It's just a signal to the host to handle the card as write protected or normal card.

If you plug it into the adapter, it is up to the host to read the switch on normal sized SD cards.

However not all hosts can even read the switch position, and even if they do, you don't get much guarantees that the host will adhere to the switch setting.

  • 1
    \$\begingroup\$ Although your answer is short, simple, and even accepted, it's also incorrect. See the answer by TurboJ for a counterexample. It's not as easy as sliding a physical switch but it can be done without too much effort. \$\endgroup\$
    – TooTea
    Commented Jun 25 at 9:53
  • 2
    \$\begingroup\$ @TooTea Justme answer is correct though. He talks about the switch, there is none \$\endgroup\$ Commented Jun 25 at 18:56
  • \$\begingroup\$ @AndrejsGasilovs: Correctly describes that there is no physical switch, yes. But incorrectly generalizes from lack of physical switch to lack of a read-only mode. \$\endgroup\$
    – Ben Voigt
    Commented Jun 27 at 14:35
  • \$\begingroup\$ @BenVoigt If you can enable a read-only mode in software, what prevents any program under any OS to send commands to disable read-only mode? \$\endgroup\$
    – Justme
    Commented Jun 27 at 16:50
  • \$\begingroup\$ @Justme: What prevents "any program" would be OS-level permissions/capability restrictions. "Does read-only mode actually prevent a fully compromised host from making ANY changes at all?" is an interesting question with a lot of rabbit holes to explore (such as logic bugs inside some models of SD card, hacking the OS to ignore the readonly signal, patching the firmware, using vendor-specific commands) but it isn't the question OP asked. The correct answer to the question asked is likely to be "You CAN enter read-only mode with CMD27 but it isn't total protection." \$\endgroup\$
    – Ben Voigt
    Commented Jun 27 at 19:08

There is no easy way to access the two "read only" bits in the cards CSD register - it cannot be accessed directly with an USB-to-SD or mobile phone type device (AFAIK).

But there are some microcontoller (e.g. Arduino, RPi etc) projects that can change these bits. There is one bit that can be re-written and one that permanently changes the card to read-only mode.

And there is software available on github.

  • \$\begingroup\$ I vaguely recall that you can do this on an Android phone through the adb interface. \$\endgroup\$
    – Sneftel
    Commented Jun 26 at 8:59
  • \$\begingroup\$ Thanks TurboJ for the answer, it is very informative. I do believe it should be marked as the actual answer, but I feel the one I decided to mark "you can't" is the straight forward one. And it was all about the switch and be done by regular user without any of that crazy programming stuff. \$\endgroup\$
    – ADM-IT
    Commented Jun 26 at 14:49
  • \$\begingroup\$ I presume there is no equivalent for USB "thumb drives", though there are USB shells that wrap around micro USB. The best I've been able to find are USB protocol filters, and even those only in expensive development/forensic tools. I really miss the days when all removable storage media had physical write protect features. \$\endgroup\$
    – keshlam
    Commented Jun 26 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.