• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Solaris : Troubleshooting startup (rc init) scripts

by admin

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 :

/etc/rc3.d/K*
/etc/rc3.d/S*

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.
rc4 Unused
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.

Troubleshooting

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

Example

# head -2 /etc/rc3.d/S50apache
#!/sbin/sh
set -x
...

which shows output in /var/svc/log/milestone-multi-user-server:default.log after reboot.

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.

3. 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.

4. 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

Filed Under: Solaris

Some more articles you might also be interested in …

  1. Comparing Network configuration : Solaris 10 Vs Solaris 11
  2. A beginners guide to Veritas Dynamic Multipathing (VxDMP)
  3. A beginners guide to Solaris Multipathing Software (MPxIO or STMS)
  4. Solaris (SPARC) : How to create OBP boot device alias at ok prompt
  5. Solaris Snoop : 15 Awesome practical examples for packet sniffing
  6. How to allow only specific non-root user(s) to use crontab
  7. GUDS – A Script for Gathering Solaris Performance Data
  8. How to find Number of Physical/Logical CPUs, cores and memory in Solaris
  9. Troubleshooting Solaris IPMP
  10. 17 Examples of using Solaris boot command

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright