Faster /etc/rc.d

The startup files are written in a pretty general fashion, extracting the needed configuration information from a multitude of configuration files. While this has the advantage, that you can easily add/remove the components which must run in a certain run-level, it slows down the startup process. The need to first extract command parameters from configuration files does even more slow down things.

Looking at the /etc/inittab I saw, that the whole initialisation is based onto the two scripts rc.sysinit and rc. rc.sysinit is started just once when the system boots. rc is started after rc.sysinit to establish the startup run-level, as well as each time the run level is changed using the command telinit.

After reducing these files, it takes only 6 seconds until I get a console login prompt. So total boot time, from BootX to login prompt is 19 seconds.

The missing link is now, how to start booting Linux right after switching on my PowerBook. It takes now 25 seconds until BootX appears.


This script has to perform all initalisation needed when the system is started up, are independent of the run-level, and are not undone when a run-level change is performed.

My rc.sysinit file.


This script is called with the desired run-level as argument. The run-level is a handy way to define several operation modes of the OS. Depending on the value of the run-level, some services are started or stopped. These are the run-levels as predefined in LinuxPPC:

1Single user mode
2Multiuser without network servers
3Full multiuser mode

As I use linux on a notbeook, which is rarely attached to a network, it makes no sense to have two different multiuser modes. Also I think I will not used xdm login, but start X after having logged in textually. So I will not use run-level 3 and 5. This means I can remove the line which executes prefdm from the inittab file.

When this script is called, it will basically execute all scripts contained in the directory /etc/rc.d/rc.runlevel either with the argument stop, if the script name starts with K or with argument start, if the script starts with letter S. The scripts are really just links into the /etc/rc.d/init.d directory. Depending on whether the script shall be called with argument start or stop, a link in the run-level directory is created with a name starting with K or S.

Now my idea to speed up startup, is to have just the rc script, and do everything in there. The script shall be very compact, and contain also all of the configuration stuff. Nevertheless, it shall be easily readable/understandable.

Having on 2 "non-shutdown" run-levels, 1 for single-user and 2 for multi-user mode, makes everything easier. I also assume, that if I ever switch from a run-level to the same one, it is ok to restart all servers.

Thus I created a script, which first stops almost everything. Then it looks, if run-level 0 or 6 were selected. In this case some further "stopping" actions are performed, and the system is powered off or rebooted. Otherwise it will first perform setups and start services needed for both run-level 1 and 2. If run-level 2 was selected additional setup-startup takes place.

My rc file.

Last updated: 1999-08-18 by Claudio Nieder