Previous Page | Next Page

  1. Introduction
  2. Boot Process
  3. Init and System Initialization
  4. rc.sysinit script
  5. rc script
  6. functions script
  7. Services
  8. apm daemon
  9. network startup
  10. The network script file
  11. The network-functions file
  12. Portmap startup
  13. Random initialization
  14. Syslog initialization
  15. Gated
  16. Atd
  17. cron initialization
  18. pcmcia
  19. inetd daemon
  20. named daemon
  21. lpd daemon
  22. mars-nwe
  23. netfs startup
  24. dhcpd daemon
  25. autofs daemon
  26. keytable daemon
  27. sendmail daemon
  28. gpm daemon
  29. httpd daemon
  30. xfs startup
  31. smb startup
  32. innd startup
  33. linuxconf startup
  34. rc.local script
  35. Init, Getty, Login
  36. The shell
  37. Shutting down
  38. X
  39. Conclusions
  40. App A. rc.sysinit listing
  41. App B. functions listing
  42. App C. rc listing
  43. Credits

Shutting Linux Down

To shutdown the system, the system administrator will type something like "shutdown h now". This will invoke the shutdown program which signals the init process (still running as a daemon) to change the runlevel to run level 0. Run level 0 is used to halt the system, and runlevel 6 is used to reboot the system. Then init is told to change the runlevel, it will send the SIGTERM signal to all processes not defined in the new runlevel. Then init will wait 5 seconds and send the SIGKILL signal, forcibly terminating these processes.

Then init will run the script file "/etc/rc.d/rc" which runs all kill scripts, then all startup scripts, of course in run level 0, there are no startup scripts. Kill scripts are run with the command "action "Stopping $subsys" $I stop". Basically this means that all kill scripts are run with the stop option. The stop scripts are generally run in reverse order from the way the startup scripts are run. This is because you would want to do things like unmount file systems after running all other programs, since many subsystems are set to depend on other subsystems. Note, that the last kill script is "/etc/rc.d/init.d/halt". This script takes care of unmounting all filesystems with the command "umount -a" which unmounts all file systems in "/etc/fstab" (filesystem table). Therefore if you mount filesystems after the system is booted, you don't have to worry about unmounting it if you are worried about a graceful shutdown. The system takes care of it.