Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

arsv/sninit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview
~~~~~~~~
sninit is a small init implementation for linux.

It is meant to be a cleaner and more reliable replacement
for sysvinit/initscripts combo, providing better control over
foreground processes and removing the need for initscripts.

Alternatively, it is a much much smaller systemd replacement
for systems that need basic systemctl but would rather avoid
bringing in enormous systemd bundle.

sninit is written mostly in raw syscalls and has no external
dependencies on supported architectures — not even libc.


Project status
~~~~~~~~~~~~~~
This project is FINISHED. Further development now happens here:

    https://github.com/arsv/minibase
    (also mirrored at notabug.org and gitlab.com)

That project has moved away from SysV-style init to a split-stage design
similar to daemontool/runit/s6, with the supervisor handling uniform
unordered set of respawning children. See doc/others.txt here on how
it relates to sninit and other inits.

Process supervision parts of sninit ended up in svchub, command parsing
code and the `run` tool got merged to become msh.


Key features
~~~~~~~~~~~~

+ SysV-style sequential inittab
+ SysV-style runlevels for process management
+ Support for initdir in addition to inittab
  (one file per process vs one line per process)
+ Sleep/suspend/hibernate as runlevels
+ Telinit commands to start/stop individual processes
  ("telinit stop httpd" and so on)
+ Small size and static linkage
+ Simplified memory management;
  no malloc, memory allocation only while reconfiguring

the following is not in sninit:

- built-in system state management (network/mounts/sysconfig/ulimits)
- inter-process dependencies, systemd-style
- support for kernels other than linux-2.6+
- dbus, xml and other bloat
- wall(8), shutdown(8) and some other sysvinit utilities
- in-place restarting a-la sysvinit

sninit features that are not in any way exceptional:

* proper process supervision
* parallel startups
  (both can be done even with busybox init)


What is init
~~~~~~~~~~~~
init is process 1 in Linux and other Unix-like systems.

Upon booting itself, linux kernel only starts one process, /sbin/init.
This process is expected to initialize the system and start everything else,
including user interface.
This process is not expected to exit; in case it does, kernel panic happens.

Init starts several processes in sequence, waiting for them to finish,
mounting filesystems, initializing devices and so on.
Once the system is ready, init starts daemon-like processes, and keeps
respawning them in case they die.

Daemon-like processes usually include getty (with login as a subprocess),
xinit or X display manager, as well as actual daemons in foreground mode.


Building sninit
~~~~~~~~~~~~~~~
For proper build instructions, see INSTALL file.

To try sninit without configuring a VM or installing anything:

	./configure devel
	make
	./init
	(from another terminal)
	./telinit list
	./telinit stop srv1
	./telinit sleep
	(feel free to change things in ./etc at this point)
	./telinit reload
	./telinit poweroff

In this configuration, init uses ./etc/inittab, ./etc/initdir
and stub executables from ./sbin.

For more involved testing, check doc/buildroot.txt.


Just how small exactly?
~~~~~~~~~~~~~~~~~~~~~~~
Typical size of statically-linked, stripped executables:

                     init     telinit    run
        x86          14KB       3KB      6KB
        x86_64       14KB       3KB      6KB
        arm          17KB       3KB      7KB
        arm64        17KB       3KB      6KB
        mips         25KB       4KB     10KB

telinit is a standalone executable in sninit, not a hardlink to init.
run is optional, and not really related to init at all.


Credits
~~~~~~~
sninit draws ideas from busybox init, minit and the original sysvinit.

"No-malloc" approach to memory management was inspired by rockbox,
though in rockbox itself it was done in a different way.

Small size and static linkage are mostly due to dietlibc and busybox.
See "Writing Small and Fast Software" by Felix von Leitner.

See also doc/others.txt for a list of other init implementations.


Licensing
~~~~~~~~~
GPL version 2 or any later, see COPYING.


Author
~~~~~~
Alex Suykov <[email protected]>