Raspberry Pi root file system in read-only mode

I have found my Raspberry Pi running the root file system off a USB flash drive in no good state this morning, the following error showing up on emoncms that was installed locally:

Can't connect to database, please verify credentials/configuration in settings.php
Error message: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Obviously my MySQL installation was damaged, I tried to repair based on the first couple pages that Google returned on this error, but to no avail. I wasn’t putting in too much effort into it either, as this will keep happening over and over in the power outage conditions I have here.

Anyway, this wasn’t unexpected as the USB flash drive isn’t much different from a SD card when it comes to unexpected power outages and improper shut downs, probably an external USB HDD will also suffer from this sort of abuse. Obviously I need something else, the comments to my previous post suggested that I try read-only root fs. I did research a bit then on the options, the easiest way to go is simply to use the IPE by NutCom, here is what grabbed me:

IPE – Industrial Perennial Environment is a special blackout-proof flavour of Raspbian– a Debian-based Linux Distribution for the Raspberry PI. It is of course free (considered GPL).

It’s aim is to provide a solid OS for using in environments where blackouts are common.
IPE achieves it’s goal by using a full read-only file system with slightly modified tools.

IPE will fit on a 1GB SD card, or can be automatically expanded to use any size.
Use the “firstboot” command to automatically expand to the size of the SD card, and do some basic configuration.
Also, use “ipe-rw” and “ipe-ro” to switch the root file system to writeable or read-only mode.

Looks promising and easy to set, I have downloaded the SD card image to try out. My next steps are to have the RFM2Pi board run in forward mode to external emoncms, that should be a bullet-proof gateway solution.

 

 

Page views: 13673

10 thoughts on “Raspberry Pi root file system in read-only mode

  1. Pingback: Rock-solid RFM2Pi gateway solution | Martin's corner on the web

  2. Hi Martin,
    unless you are using the pi for other tasks that do not require a read/write file system I believe you would be better off with a simpler node if the only thing you need it to perform is to forward data to a different server, like a nanodeRF or an arduino with an ethernet shield and an rfm12b shield.
    Another option, if you aren’t simply forwarding data to a hosted emoncms instance (in that case you would lose data if your internet connection goes down ) would be to still use the pi and mount a read/write file system through the network.
    I don’t have a blog post (yet) illustrating how to do it, but a lot depends on what kind of network share you are able to set up (it should be nfs for mysql, whatever for things like apache logs or sqlite dbs/file based storage)

    • I have too come to that conclusion long ago, using a DIY nanode myself. My efforts are more towards making the gateway solution more accessible to people that aren’t good at micro controllers and programming, the Raspberry Pi is a better option for them.
      Network mounted R/W file systems sounds like an interesting thing to try out.

      • You can make even root fs on Pi to be on NFS, but you have to keep SD for boot.

        I never manage to have stable OS on Pi with SD, but with NFS root my Pi is up now from 42 days and before that it was up for something like 80+ days and only was rebooted because of power outage. And until your NFS server is up you don’t have to worry about Pi being turned off and on.

  3. Thank you, Martin, for writing these articles. I have a question: I have a simple Raspberry Pi controlling a solid-state relay through the GPIO pins. I often find the SD card corrupted, and I have to start my installation from scratch.
    A few days ago, when I read your blog entry about starting to use a USB flash drive, I switched to booting from a USB flash drive. But I became worried when I read your comment below the article about how it didn’t work out as you had hoped. So now I’m thinking I may need to switch to IPE, but it sounds like IPE might only be useful if I never want to write to storage, which I definitely do. I just don’t want the file system to get corrupted every time I turn around. Can you provide any guidance? I’m hoping I can somehow tweak Raspbian to prevent these errors.
    Thanks again for your blog!

    • Hi,
      You could use an external USB HDD instead of flash drive and not have these worries. The procedure of switching will be the similar, just mind the paths. External HDD will require additional powered USB switch OR as in my case, I have a Transcend HDD that has its own power supply in addition to the USB power.
      IPE can be temporarily switched to R/W mode, but that is just to update something and then revert the setting.

      • I see. For now, I’d like to stick with USB flash drives and SD cards to keep costs down.
        I’ve been reading around about IPE, and I can’t seem to find much about how it works. Have you found an article stating what changes it makes to Raspbian so that no hard drive writes are allowed? If I could modify Raspbian myself, I would rather do that.
        For now, I’ve found some pages about extending SD card life by disabling or removing processes from Rasbpian.

  4. A bit late to the party here, but still..

    After having a couple of SD cards (both Kingston 16 GB, btw) corrupted in the Raspi I intended to use for various hardware related always-on things, IPE sounded like a terrific idea.

    So I set up IPE and all was good, until a day or two ago (after only ca 3 weeks, really).
    The Raspi would not respond to ssh, and after power cycling it, it refused to boot. Exactly the same symptoms as with the previous corrupt SD cards. Oh yes, this third card was also Kingston. No idea whether they make crappy cards in general, or if this is something else.

    It DOES disturb me that a readonly system would crash after such short time.
    In IPE, there should be no writes done at all to the SD card, right?

    Hmm…

    • Hmm, strange indeed. It is not possible to damage the SD card in R/O mode, I mutilate mine by cutting off power at any time and hasn’t seen any issues for months and months now (touching wood). Would it be possible that you forgot yours in RW mode during a ssh session? Also: DO get a good power supply, it does matter. I use one from a tablet, I did have freezes before due to bad power supply and with R/O file system, those are all gone now with my new power supply. Aim for 1.2+ amp one.

Comments are closed.