FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next 

System startup - step III


Notes:

  1. Inittab is the first configuration file for init, but that is not the end of the story. There are also a whole set of scripts that run on system startup or shutdown that control exactly which daemons are stopped or started and any other tasks that need to be done.
     

  2. In a Debian Linux system, all scripts that are run at startup or on a change of runlevel are stored in the directory /etc/init.d
     

  3. The directory /etc/rcS.d controls which of the scripts from /etc/init.d are run at startup.
    The directory /etc/rc0.d controls which of the scripts are run on a change to runlevel 0.
    The directory /etc/rc1.d controls which of the scripts are run on a change to runlevel 1.
    The directory /etc/rc2.d controls which of the scripts are run on a change to runlevel 2.
    etc.
     

  4. Each of the "rc" directories contains symbolic links to the required scripts in /etc/init.d. The links are either "S" links which start a service or "K" links which kill a service. Each of the linknames must start with an uppercase S or K followed by a 2 digit sequence number. The K links will be executed first in order followed by the S links.
     

  5. For example: in floppix, /etc/rc6.d contains these links:

  6. You can change the tasks that are performed for each runlevel by either


Exercises:

  1. Answer the following questions about the current setup:
    1. What is the default runlevel for floppix?  _____
    2. What directory contains the S and K links for this runlevel? _____
    3. What K links (if any) exist for this runlevel? _________________________
    4. What S links (if any) exist for this runlevel? _________________________
    5. What command will show you if the following services are running: syslogd, klogd, icmplogd, tcplogd (they should be but check and make sure that they are)
       
  2. Configure rc2.d so that syslogd, klogd, icmplogd and tplogd do not startup in runlevel
    1. Change to the directory /etc/rc2.d
    2. Delete the link that starts up syslogd and klogd. (you will have to look at the contents of the individual scripts to see which link to delete)
    3. Delete the link that starts up icmplogd and tcplogd.
    4. Switch to runlevel 1 and then back to runlevel 2.
    5. Verify that syslogd, klogd, icmplogd and tcplogd are not running.
       
  3. Add a new script that runs everytime you switch to runlevel 1.
    1. Change to the directory /etc/init.d
    2. Code a script called red that:
      • turns the screen red
      • displays the message "Entering runlevel 1"
      • displays a list of all of the processes that are currently running
    3. Make sure that your script will run.
    4. This script should run every time you change to runlevel 1. So change to the directory /etc/rc1.d
    5. Put an K link to your script in the directory rc1.d so that the script will be the first script to run when the system shuts down as follows:
      ln -s /etc/init.d/red K01red
    6. Change to runlevel 1.
    7. Did your script run?
       
  4. The scripts in /etc/init.d are can be invoked as "Kill" scripts or "Start" scripts. They are called with a stop parameter, when invoked as a "Kill" script and called with a start parameter when invoked as a "Start" script. These scripts should be structured as follows:
    # sample script
    case "$1" in
    start)
       instructions for starting a service go here
    ;;
    stop)
       instructions for stopping a service go here
    ;;
    esac


    1. Using the format shown above, code a script that does the following:
      • when the script is called with a stop parameter, it should turn the screen background colour red and then clear the screen
      • when the script is called with a start parameter, it should turn the screen background colour green and then clear the screen
    2. Test your script and make sure that it works.
    3. Put a K link to your script in /etc/rc1.d and an S link to your script in /etc/rc2.d.
    4. Test your links. Change to runlevel 1; the screen should turn red. Change back to runlevel 2; the screen should turn green.

Copyright © L.M.MacEwan
FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next