Page 1 of 1

Substituting SD card while booted

Posted: Sat Mar 28, 2015 10:14 pm
by Shankmeister
I would like to be able to use this tool: http://www.bertold.org/sdtool/ on some SD cards to render them read-only.

To be clear, the SD cards aren't the same SD card that I use to run my Pi - they are SD cards that I use for other stuff but I'd like to be confident that nothing is able to be written to them once I've got the content on them that I need.

In order to modify the CSD register, the tool requires access to the SD card as a block device (e.g., /dev/mmcblk1) and not as a USB mass storage device (e.g., /dev/sda) thus using a USB SD card reader is not an option.

What I'm thinking might be possible is to use something like this: http://www.raspipress.com/2013/05/insta ... ash-drive/ to get the Pi booted in such a way that it's not dependent on the SD card, and then remove the SD card, introduce my other SD cards (one-at-a-time), and then run the SD tool on each SD card to edit the CSD register as I require.

I'm pretty much a noob with Raspberry Pis (and new to this forum so apologies if this is the wrong subforum to post in) so before I expend too much effort in trying to get this to work, I was keen to get some feedback from those of you who know this kind of stuff about whether or not this might be possible?

Thanks...

Re: Substituting SD card while booted

Posted: Sat Mar 28, 2015 10:25 pm
by gsh
One method of doing this is to use NOOBS. NOOBS is actually a complete linux system in itself, if you trigger the noobs recovery system to open the GUI then press Ctrl-Alt-F2 you'll get to a command prompt

Login with "root" password "raspberry"

Now you can unplug the SD card and put the new one in. This should all work fine and allow you to use the Pi to access the card at a very low level. I'm just not sure whether you are going to be able to access the CSD with the software available in NOOBS... To get more you'd have to rebuild it which is a much more complex affair!

Gordon

Re: Substituting SD card while booted

Posted: Sat Mar 28, 2015 10:35 pm
by Shankmeister
Thanks Gordon - sounds like the clincher is the bit where you say "I'm just not sure whether you are going to be able to access the CSD with the software available in NOOBS..." - it's the 75KB executable 'sdtool-rpi' from bertold.org that performs the CSD edit so, without that, I guess I'm in the "you'd have to rebuild it which is a much more complex affair" territory!

Any other variations on the theme that would allow me to access SD cards as block devices using the SD tool would be very gratefully received! Thanks.

Re: Substituting SD card while booted

Posted: Sun Mar 29, 2015 5:48 pm
by gsh
If you've got the binary pre built then you should be able to write it into the RECOVERY partition and access it from there, from the command prompt it should appear in the /mnt directory

Gordon

Re: Substituting SD card while booted

Posted: Sun Mar 29, 2015 9:20 pm
by Shankmeister
Great! Thanks Gordon.

Do I need to run any specific commands to mount the newly-inserted SD cards in order to make them accessible?

Cheers!

Re: Substituting SD card while booted

Posted: Sun Mar 29, 2015 11:51 pm
by Shankmeister
So, I've tried as you suggested - hitting Shift on a reboot to boot into NOOBS. If I then press Ctrl-Alt-F2, rather than get a login prompt, I simply get a flashing white cursor in the top-left corner of the screen on a black background.

I've googled around to try to work out what I'm doing wrong, to no avail. Is it possible I've corrupted my RECOVERY partition? I'm still able to access it by mounting it from within Raspbian so it appears to be intact but, despite that, I can't access it as you propose.

Any thoughts?

Thanks again!

Re: Substituting SD card while booted

Posted: Mon Mar 30, 2015 6:24 am
by tpylkko
I've never done this, so correct me if I'm wrong

But couldn't one use a "core distro". What I mean is that there are minimal "core" OS's out there, such as PiCore, which I believe is a RPi version of Tiny Core. These mount the entire OS into RAM/tmpfs. So, I'm guessing that you could boot one and then and take out the SD-card, as the OS is not going to need to use it much?

Re: Substituting SD card while booted

Posted: Mon Mar 30, 2015 8:45 am
by ghans
Yeah , that approach should work fine (and essentially is what NOOBS recovery mode does).

ghans