this post was submitted on 07 Jan 2025
18 points (100.0% liked)

Linux 101 stuff. Questions are encouraged, noobs are welcome!

1097 readers
1 users here now

Linux introductions, tips and tutorials. Questions are encouraged. Any distro, any platform! Explicitly noob-friendly.

founded 2 years ago
MODERATORS
 

Will my OS break if I make it the system Read Only? I am installing a raspberry pi 4 (Raspberry Pi OS (64-bit)) in my car and read on Lemmy that if I make the system files Read Only my system won't get corrupt when power is abruptly turned off. I will leave the 'home' directory read-write. I realize I will have to remove the drive and run updates regularly.

top 6 comments
sorted by: hot top controversial new old
[–] theit8514 10 points 1 week ago (1 children)

A better way to do this would be to use the overlay filesystem which will use some of your RAM to hold temporary files written to the partition. When rebooting the system will start over from when you enabled the overlay filesystem.

https://learn.adafruit.com/read-only-raspberry-pi/overview

[–] floppingfish 3 points 1 week ago

Looks good! I'll give it a try. Thanks!!

[–] [email protected] 9 points 1 week ago

idk about Pi OS, but usually it will break, because all sorts of services need to write stuff in /var/ , /tmp/ or other places and they can't if it's mounted read-only. You could maybe get away with mounting tmpfs ramdisks in those places, but it will be complicated if the services expect something already there, e.g. database files.

[–] [email protected] 5 points 1 week ago

There are parts of the filesystem that will still need to be written - most of /var, /proc, etc. The good news is that those are well known, and save for some exceptions could be tmpfs mounts.

Also, most modern filesystems have journaling and are resilient to sudden powerdown events, especially if you're not writing a lot.

[–] [email protected] 3 points 1 week ago

It probably depends on what software you're running and what it does. I don't 100% know how to do this, but this is what I'd aim for:

Everything on the physical drive is read-only. On startup, it creates a RAMFS and copies any files that change as part of the software you're running there and points to that for all temporary files, etc.

That way the whole physical device is read only and anything that needs to change does so in memory only.

[–] frankenswine 2 points 1 week ago

Just try and find out! There's a bunch of parts in your File-System hierarchy that the kernel emulates (and therefore sets permission bits itself). My guess? It might work to some extent (maybe even useful enough) bit could inflict unforeseen challenges.

Have fun!