arsv / sninit Goto Github PK
View Code? Open in Web Editor NEWsmall static init for linux
License: GNU General Public License v2.0
small static init for linux
License: GNU General Public License v2.0
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]>
Init can't kill dropbear properly and fails to wait for forkreboot() to complete.
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:
/bin/cgexec args /run-as-cmd /bin/unshare args /seccomp-bpf-cmd args
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) ?
I have no qualms over the GPL but it may help adoption if given a more permissive license.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.