Git Product home page Git Product logo

sninit's Introduction

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]>

sninit's People

Contributors

arsv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sninit's Issues

aarch64 is broken

Init can't kill dropbear properly and fails to wait for forkreboot() to complete.

run: consider seccomp-bpf switches or deprecating run

Linux has a multitude of various programs that run duplicates and to be useful imo would have to push in more. There are two possible ways to go about fixing this:

  1. Create seccomp-bpf switches within run which would become massive due to individual arg checking.
  2. Create utilities to chain things together without having to use sh, hopefully as an example:
    /bin/cgexec args /run-as-cmd /bin/unshare args /seccomp-bpf-cmd args

init can be run without PID = 1

Is there a reason to be able to run init not as PID 1?
I've built my system with sninit and it's great but I also use telegraf for monitoring. Thing is, telegraf runs /sbin/init --version which doesn't do anything special in sninit - instead it attempts to reinitialize the system, along with mounting, spawning getty's, services and so on.
Can we either implement --version or at least check if we're PID 1 and if not - refuse to start (or both) ?

Initdir: Allow inittab style?

For a real world example imagine trying to allow various syslogs with the initdir where everything is a service you cannot make syslog stop at end (L) and editing and commenting inittab everytime a user changes something is brittle.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.