ninit - install instructions

It's possible to install ninit using glibc and system commands included here. On my box the executable are smaller than these compiled with dietlibc. I prepared the directories
  system/i386
  system/x64_86
In each make program builds the file system.a. Using this library and ninit.a the linker create executable in bin-$(ARCH) dir. It don't use any other functions. If one have dietlibc installed already the linker uses it instead of system/$(ARCH)/system.a

Try this with:

  $ make clean
  $ make i386
  $ make tests

  $ cp bin-i386/* .
  $ make tests
On x86_64 replace i386 with x86_64 above. On my box ninit compiled with above command uses only 12K RAM. There are 3 pages = text + data + stack.

The ".data + .bss" page is very small. It is less than 120 bytes. One can merge it with ".text" and then ninit will run with 8K only. Test this with

  $ rm bin-i386/*
  $ make i386 TINY_LDFLAGS=-Wl,-N

  $ cp bin-i386/* .
  $ make tests
The option -Wl,-N is for the linker. It is possible to use also other flags. For example -Wl,-znoexecstack. Last is coded in Makefile. Simple try
  $ make x86_64
to see the results.
vladov@riemann:0 ~/public_html/ninit$ ps axuw | head -3
  USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
  root   1  0.0  0.0   8   8 ?      S Oct08 0:03 /sbin/ninit
  root   2  0.0  0.0   0   0 ?      S Oct08 0:02 [keventd]

On the other architectures you need to use dietlibs, or prepare subdirs in system.

Warning

Some distros make precompiled binaries. Let we assume the following scenario. The OS process no 1 is /sbin/ninit. The install instructions overwrite /sbin/ninit. The old ninit continues to work, nsvc is updated already. It is even impossible to halt clean, since
	/bin/mount -o remount,ro /
fails (device busy). It is better to use somethinig like:
	#!/bin/sh
	data=/tmp/ninit-$$.data
	grep ninit /proc/1/cmdline
	ninit=$?

	if test $ninit -eq 0 ; then
		rm -f $data
		/sbin/ninit-reload -d > $data
	fi

	# apply the distro install instructions here
	# they should overwrite /sbin/ninit, /sbin/ninit-reload

	if test $ninit -eq 0 ; then
		/sbin/ninit-reload -f $data -v -u /sbin/ninit
		rm -f $data
	fi
See also scripts/update.sh in the source.
Some shell related questions are discussed here.

Last updated: 17 Jan 2010