Creating a readonly system [solved]

Dear all,

this is my first post - I could not find anybody mentioning a similar problem here - maybe the community can help (and I guess this topic is also interesting for others).

My name is Birk, I’m utilizing quiet some raspberry for different purposes (Video recorder, pihole, home automation, octoprint) and I really like the lightweight dietPi distribution.

My goal it to create a dietpi read only system. Application would be something like a small webradio using mpd, maybe an octoprint, printserver etc.
Major goal: I just want to “switch it off” (This also increases highly the WAF (woman acceptance factor)) :stuck_out_tongue: without shutting the system down.

I got more or less everything working using my script which I published here: (relevant lines: 46-73)

only thing missing is the resolv.conf
I tried several solutions:

  1. Simply move it to /tmp and create a symbolic link to it
  2. Create a dhclient-enter-hooks (seems to create the destination file to late)
  3. Modify the /sbin/dhclient-script

The symbolic link solution is recommended in a lot of Linux posts but unfortunately doesn’t do the trick.

I using some Raspberry first generation and 3rd generation systems.

Hope somebody can give a hint.

I just tried another thing:

I put the following scrip here /etc/network/if-pre-up.d/c_resolve


/usr/bin/touch /tmp/resolv.conf
chmod 777 /tmp/resolv.conf
echo "#hello world - preup" >>/tmp/resolv.conf

It creates the resolv.conf (I also see three times the hello world) but unfortunately the real nameserver information are not written to it…

It turned out I overlooked that in the original (not tinkert system) the file /etc/resolv.conf is itself a symbolic link to /etc/resolvconf/run/resolv.conf
Due to the fact that /etc/resolvconf/run is a symbolic link to /run and my script mounts /run on a tmp filesystem… nothing to do.

If anybody is interested: I posted the now working script here:

Does this script works with the latest version of dietpi?