ninit - a small replacement of init

Release:   ninit-0.14.tar.bz2
Author's private /etc/ninit/   ninit-data.tar.gz :: archlinux

The ninit security guarantee

What's new


ninit is a fork from Felix von Leitner's minit. Some other related links.
There is a mailing list for ninit. To subscribe, send an empty message to
Some delay is possible due to greylisting.

ninit uses minimal resources (arch: i386; kernel: 2.4.37):

  root   1  0.0  0.0   8   8 ?      S Oct08 0:03 /sbin/ninit

   text    data     bss     dec     hex filename
   3642      20      56    3718     e86 /sbin/ninit


You have to build and install ninit first. I prefer to do this with Fefe's dietlibc.
Download the latest stabe ninit-0.14.tar.bz2 release. Then:
  bzip2 -dc ninit-0.14.tar.bz2 | tar -xvf - 
  cd ninit-0.14

Case-A:  If you have dietlibc already working do:
  $ make withdiet;   make tests
  # make install

Case-B:  If you do not have dietlibc do:
  $ make dietbuild;  make tests
  # make install
To compile ninit with glibc do:
  $ make nodiet;     make tests
  # make install
Only make install must be started as root! Other install instructions are here. You can type also make strip before make install. The distributions should read this warning.

Post install

You have to prepare service directory /etc/ninit and to setup
boot loader (grub or lilo) to start /sbin/ninit instead of /sbin/init

Preparing directory /etc/ninit

Case A. If you already have ninit running, then you already have this directory and can skip to updating ninit.

Case B. If you already have minit running do simply:

  cd /etc  &&  cp -p -R minit/* ninit
Case C. If your default init is /sbin/init it's also easy.
I wrote a simple converter ninit-inittab. Try it with:
  /sbin/ninit-inittab /etc/inittab /etc/ninit /tmp/
Last two commands are equivalent to:
  make ser_vi_ces

Setup lilo/grub to boot /sbin/ninit

To use ninit as system init add the parameter init=/sbin/ninit
to your kernel command line. See some short instructions here.
After that you have to reboot the system.

Updating ninit

If ninit is already running your boot loader is already prepared to start /sbin/ninit. After installation all is done automatically. Simply do nothing more!

You can test the new executable (before make install) also with:

	/sbin/ninit-reload -v -u /path/to/new/ninit
	cp /path/to/new/ninit /sbin
	cp /path/to/new/ninit-reload /sbin
	/sbin/ninit-reload -v -u /sbin/ninit

How it works

For ninit, everything is a service, which should either be started once or respawned. Ninit expects its configuration in the /etc/ninit directory. You have to create all services in this directory manually or using the program ninit-inittab. My private ninit-data.tar.gz and ls-R are also public.

Ninit searches for a file called depends in the subdirectory default. This file tells ninit which services should be started by default (in fact it tells ninit that the service default depends on other services, but default is the directory ninit starts to search in). Instead of the file default/depends it is possible to start services with ninit-scan.

Ninit doesn't start services alone. It uses the helper program /etc/ninit/sys/run to start a service. On this way ninit doesn't parse the service instructions in the corresponding directory. This keeps ninit small and it's easy to change /etc/ninit/sys/run.

There is a companion utility /bin/nsvc that can be used much in the same way as the svc from daemontools. Communication works over two fifos, /etc/ninit/{in|out}. Those have to exist before ninit is started and they should be owned by root and have mode 600.

While sys/run is the main ninit helper, there are also four auxiliary helpers ninit-pidfile, pututmpid, ninit-runlevel and ninit-sysvinit used to start services. The last three helpers emulate /sbin/init behavior.

Shutdown and reboot

On a box running ninit as process no 1 it is better to avoid using the SysVinit programs shutdown, reboot, and halt. First, check the directory /etc/ninit. Assuming you have the services {_l0|halt} and {_l6|reboot}, you can try
	nsvc -o halt
	nsvc -o reboot
If you have service ctrlaltdel then CTRL-ALT-DELETE halts the hox.

The converter ninit-inittab can usually create these services for you. If they are still missing, the last choice is to use the program ninit-shutdown, or alternatively the SysVinit programs shutdown, reboot, halt. Other problems with halt are described here..


See also

Here are the package README and CHANGES. Almost all for minit is true for ninit also.
Other related links.

Author: Nikola Vladov

If you like ninit, try also my ngetty - single daemon for all virtual consoles.
Send comments and suggestions using ninit mailing-list or qform.
WARNING: ninit is tested only on i386 and x86_64 arch.

Last modified: Feb 11 2010