Chapter 6. Creating system boot scripts

Table of Contents
Preparing the directories and master files
Creating the reboot script
Creating the halt script
Creating the mountfs script
Creating the umountfs script
Creating the sendsignals script
Creating the checkroot script
Creating the sysklogd script
Setting up symlinks and permissions
Creating the /etc/fstab file

These bootscripts are started at system boot time. The scripts are responsible for mounting the root file system in read-write mode, activating swap, setting up some system settings and starting the various daemons that our system needs.

Preparing the directories and master files

You need the Sysvinit package again for this section.

We need to start by creating a few extra directories that are used by the boot scripts. Create these directories by running:



root:~# cd /etc
root:/etc# mkdir rc0.d rc1.d rc2.d rc3.d
root:/etc# mkdir rc4.d rc5.d rc6.d init.d rcS.d

Go to the unpacked Sysvinit source directory and copy the Debian/etc/init.d/rc file to /etc/init.d by running:



root:~# cp /usr/src/sysvinit-2.78/debian/etc/init.d/rc /etc/init.d

The second boot script is called rcS and we'll create that one from scratch. Create a new file /etc/init.d/rcS containing the following:



#!/bin/sh
# Begin /etc/init.d/rcS

runlevel=S
prevlevel=N
umask 022
export runlevel prevlevel

trap ":" INT QUIT TSTP

for i in /etc/rcS.d/S??*
do
  [ ! -f  "$i" ] && continue;
    $i start       
done

# End /etc/init.d/rcS