tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: porting the nitro init system
On Fri, Sep 05, 2025 at 08:37:06 +0200, Emile `iMil' Heitor wrote:
> I'm working on porting nitro https://github.com/leahneukirchen/nitro to
> NetBSD, the code is already pretty good and portable, but I am
> struggling at finding "the right way" of doing something.
>
> I want to be able to use nitro as a direct replacement for init(8) (just
> for fun, don't worry), thing is nitro relies on either:
>
> - /run for Linux systems
> - /var/run for others
>
> It uses those directories to create a control socket before anything
> else.
>
> NetBSD boots read-only, and at this stage of the boot, nothing is
> writable yet, but no problem, we can use mount(2) to create a tmpfs
> filesystem just for that. OK, but where?
>
> /var and /tmp could be later mounted by fstab other mountpoints.
> Creating a dedicated /run directory works but doesn't feel right.
>
> Any correct idea comes to mind?
Just use /run?
As far as I understand (and I'm going on guesses and hearsay here)
/var was introduced along with NFS. In a networked environment your
/usr was a shared filesystem that all your (homogenous) client
machines (e.g. a bunch of SS1) used, so logs, etc, that were VARiable
between them could no longer live in /usr/log &c as they used to, and
requiured a separate filesystem - hence /var (for variable, i.e.
per-machine).
I will omit the enumeration of possible permuations of how /var can
live in the root fs (either local or remote) or be a separate
partition to prevent overflowing logs from clutterig the root, and how
memory-fs /var/run enters the picture when the growing amounts of RAM
makes that practical.
In such a setup /var/run introduces a potential problem. If /var is a
separate filesystem (and not a subdir in the machine-private root fs)
it must be mounted by rc (started by init), but if init itself wants
to create something in /var/run we get exactly the chicken-and-egg
situation you describe.
A memory filesystem created by init and mounted on /run avoids this
dependency on /var being mounted.
Just create /run, make your /var/run a symlink to ../run and mount
memfs /run in your init.
-uwe
Home |
Main Index |
Thread Index |
Old Index