Rock4SE - protect microSD card from corruption

Hi,

I’m very new to all this and have been trying to work on a few things with my new rock4SE. I want to use it for simple websites (will probably get 0 visitors, but that’s fine) and internal photosharing.
I’ve got things to setup with ubuntu 22.04 and using virtualmin to run a site, but with a small power failure, all the efforts disappeared with no rebooting. Perhaps corrupted SD card.

I’ve read around and thought of some things, but would like some guidance from the community if possible.

- partition SD card to 1 - OS, 2 - temporary and 3 - other
- make the OS portion read only so it doesn’t get corrupted

Is this easy to do and possible? I know I can do UPS and backup power, but to be honest, it’s not that crucial of a project, and curious to see if this kind of thing can work.

Any help is appreciated!

Kind Regards

Use

Hi, thanks for the suggestion. Is this though in addition to all that I was trying to in lieu of? I see that once you flash the SD card, there are about 4 different volumes/partitions? Do they all need to be RO or is there one that needs to be writable for temp files?

It provides a great mode that loads the /root readonly into an overlayfs file system with zram upper and only writes to SD on shutdown. So its write-once on shutdown and its what openHab use or at least it did.

So installing this will essentially configure RO sections for ubuntu and I don’t need to setup anything else? Of course, trying to eliminate power issues is one thing, but a sudden loss of power with this zram-config protects it?

I’m very new to all this so making sure I understand what’s going on! Lots of learnging to do.

It used to was just instal set the mode and reboot and job done. Prob ask the repo owner or OpenHab as just haven’t bothered using for a while now.
Its even slightly better than RO as its writes the top layer down on shutdown.

Sounds like a really great solution upon re-reading again and getting my head around the solution. Seems like it’ll be less overhead too and is super efficient. Thanks again and I’ll give this a try!

You will have to report back if things have changed but it was called ephemeral mode.

Perhaps shorter way - armbian comes with all sorts of fs optimisations and zram OOB so you only need to enable overlayroofs https://spin.atomicobject.com/2015/03/10/protecting-ubuntu-root-filesystem/

This overlaysfs can also be enabled via armbian-config (“enable virtual RO mode” or something)

OverlayFS lacks tools but is a standard linux package but https://github.com/kmxz/overlayfs-tools is used for the merge down.
As on shutdown the upper is pushed down on the lower.
UnionFS has great tools but needs special kernel inclusion or at least did a year or 2 ago.

Also with zram-config you don’t need further packages such as log2ram as it can all be configured from the same point as log 2 ram is just a bind mount and being in ram it makes much more sense to use zram.
For most scenario’s as SD gets ever more robust the majoirty of writes in a Linux system are often logs and bind mounting /var/log to zram whilst writing on shutdown can be very useful but also choosing Zstandard for text compression can work much better than lz0-rle as lz0-rle works better for binaries and swap than Zstandard.

Some use Armbian and likely would myself if it was more vanilla and its scripts where repo packages with choice of install than embedded already in an image that can seem to change on whim that forces you to know armbian in entirety than just the package you may want to use.
If you find Armbian useful maybe think of donating.

wow ok, that looks interesting, something to consider for sure. I’ve done so many flash and installs as I probably keep messing up with all these commands, i’d be happy to test this out too and if it makes things easier as I don’t need anything complex.

I’m assuming virtualmin and photoprism and many other things that run on ubuntu works on armbian as well? probably silly question but to make sure!

I guess what I mean is, I managed to setup cloudflare DDNS and virtualmin etc via commandline, is that all the same with armbian?

Seems a Docker app so likely yes as for virtualmin I would have a look at Cockpit and its array of plugins.

Great. I might give cockpit a try again, I couldn’t really figure it out but managed to figure out in virtualmin (but that’s after quite a few trials) and I think I know a bit more than when I started.

Thanks for the suggestions, i’ll see how it goes with zram-config first (I just installed it, didn’t tweak any settings, but presuming it’s automagic!), and then try out armbian and cockpit.

1 Like