During boot or shutdown, a number of legacy rc init scripts are being invoked. After kernel starts the svc.startd daemon during boot process, svc.startd daemon executes the rc scripts in the /sbin directory based upon the run level. With each run level has an associated script in the /sbin directory.
# ls -l /sbin/rc? -rwxr--r-- 3 root sys 1678 Sep 20 2012 /sbin/rc0 -rwxr--r-- 1 root sys 2031 Sep 20 2012 /sbin/rc1 -rwxr--r-- 1 root sys 2046 Sep 20 2012 /sbin/rc2 -rwxr--r-- 1 root sys 1969 Sep 20 2012 /sbin/rc3 -rwxr--r-- 3 root sys 1678 Sep 20 2012 /sbin/rc5 -rwxr--r-- 3 root sys 1678 Sep 20 2012 /sbin/rc6 -rwxr--r-- 1 root sys 4069 Sep 20 2012 /sbin/rcS
Each rc script runs the corresponding /etc/rc?.d/K* and /etc/rc?.d/S* scripts. For example for a run level 3, below scripts will be executed by /sbin/rc3 :
The syntax of start and stop run scripts is
S##name_of_script - Start run control scripts K##name_of_scrips - Stop run control scripts
Note the S and K in caps. Scripts starting with small s and k will be ignored. This can be used to disable a script for that particular run level.
Tasks performed by rc scripts
Every run level is associated with a set of rc scripts which performs specific jobs at that run level.
|RC scripts||Tasks Performed|
|rc0||Shuts down and starts the system so that it is safe to power off. It also shuts down system services and daemons, kills running processes and unmounts file systems.|
|rc1||Brings the system into single-user mode. It also stops system services and daemons, kills running processes and unmounts file systems.|
|rc2||“Starts multiuser operation, but without networking and NFS support. It also cleans up “”/tmp”” and “”/var/tmp”” directories, loads the network interfaces, and starts cron, lp, and sendmail.”|
|rc3||Starts normal multiuser mode. Executes tasks in run state 2 and starts the NFS daemons.|
|rc5||Starts an interactive software reboot. It prompts for an alternate boot device.|
|rc6||Reboots the system.|
|rcS,s||Starts single-user state with some file systems mounted.|
1. Setting debug mode in RC scripts
To debug a legacy rc init scripts in Solaris 10, a ‘set -x’ can be added temporarily to second line in script to show behavior of the script
# head -2 /etc/rc3.d/S50apache #!/sbin/sh set -x ...
which shows output in
2. Check syntax
The startup script file starts with a “S” and kill script start with a “K”. Makes ure the uppercase “S” and “K” are in place on appropriate script. Changing S to K or making the letters lowercase will cause change the functionality of the script.
Identifying which rc level script will get executed
The /etc/inittab file determines which rc level scripts will get executed depending on the run level the system is booted to. Makes sure the rc scripts are in place in correct rc script folder.
3. Check the soft links and permissions
Check for the correct soft links and permissions for below files/directories.
# ls -lrt /etc/rc? lrwxrwxrwx 1 root root 11 Nov 23 2014 /etc/rc0 -> ../sbin/rc0 lrwxrwxrwx 1 root root 11 Nov 23 2014 /etc/rc1 -> ../sbin/rc1 lrwxrwxrwx 1 root root 11 Nov 23 2014 /etc/rc2 -> ../sbin/rc2 lrwxrwxrwx 1 root root 11 Nov 23 2014 /etc/rc3 -> ../sbin/rc3 lrwxrwxrwx 1 root root 11 Nov 23 2014 /etc/rc5 -> ../sbin/rc5 lrwxrwxrwx 1 root root 11 Nov 23 2014 /etc/rc6 -> ../sbin/rc6 lrwxrwxrwx 1 root root 11 Nov 23 2014 /etc/rcS -> ../sbin/rcS
# ls -lrt /etc/init lrwxrwxrwx 1 root root 12 Nov 23 2014 /etc/init -> ../sbin/init