1

We have the following setup:

  • A read-only system partition from which the kernel is booted from. (Debian Jessie)
  • A read-write partition which has additional software to be started as daemons.
  • A simple custom startup script on the r/w partition to start the daemons. This script is started as last service from the systemd on the r/o partition.

How can I leverage a modern init variant (systemd/init/initng/...) to (independently from the r/o systemd) start the stuff on the r/w partition?

  • You could configure a container which will be launched by your "ro-root-system". The container can have its root on the rw-partition. Alternatively you could just write systemd units for each daemon. – sebasth Jun 14 '18 at 8:15
  • @sebasth The system is too resource-constraint for a container. And I can't plug the daemons into the regular systemd because of the read-only nature of the system-partition. – astifter Jun 14 '18 at 12:39
  • LXC containers are quite lightweight using Linux namespaces (mount, PID, network, ...). You can avoid having redundant system files by configuring bind mounts to common binaries and other common files. Your init system would need its own configuration, but if necessary you can also bind mount them to /etc in your container's namespace. – sebasth Jun 14 '18 at 13:09
0

You can use an overlay mount to act on both sets of startup scripts transparently, with the caveat that services specified on the RW partition shadow those on the RO one.

Suppose for concreteness in this description that you are using systemd, that the RO partition is the root partition, and that the RW partition is mounted at /rw and contains two directories, systemd and work. You can do an overlay mount as follows:

mount -t overlay -o lowerdir=/etc/systemd,upperdir=/rw/systemd,workdir=/rw/work overlay /etc/systemd

This can be specified in /etc/fstab:

# Previous fstab entries to ensure /rw is mounted
overlay /etc/systemd overlay lowerdir=/etc/systemd,upperdir=/rw/systemd,workdir=/rw/work 0 0

With this fstab entry the two directories will be merged at boot and will appear to systemd (and everything else) as a single set of startup scripts. Attempts to write to /etc/systemd will be redirected to the RW partition.

This method isn't specific to systemd. It generalizes to any init system that acts on the contents of some directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.