Linux Boot Camp: How Linux Boots (part 1) - page 2
Linux Boot Camp Part I: SysV Init
Once init knows the runlevel, it passes control to a master script that will run the rest of the boot scripts. Its exact location varies, but look for something with a name like /etc/init.d/rc.
The files in /etc/rc2.d are symbolic links with names like K09apache2@ and S20postfix. The scripts they reference live in /etc/init.d:
$ ls -l /etc/rc2.d/S20postfix lrwxrwxrwx 1 root root 17 2009-10-04 12:57 /etc/rc2.d/S20postfix -> ../init.d/postfix
The "S" in S20postfix means the script will be run with the argument "start" when entering that runlevel. A "K" (kill) means the script will be run with the argument "stop". Most init scripts can take a few other arguments, such as "restart", useful if you ever need to run them by hand or via the service command.
The "20" indicates how early the script will be run. Startup scripts are run in numerical order, so S10sysklogd will be run very early in the boot process, S99acpi-support near the end.
One of the last scripts to run is S99rc.local. All it does is look for a file called /etc/rc.local and run it. rc.local is a great place to put special commands you want on your own personal system.
We're almost done! On Gnome systems, one of the last init scripts executed is S99gdm (S99kdm on KDE systems). The Gnome or KDE Display Manager starts X and gives you your login screen. Without it, you'd boot to a text console prompt.
And your system is booted, running X, and waiting for you to log in! All by means of a few shell scripts.
Akkana Peck is a freelance programmer and writer, and author of the book Beginning GIMP: From Novice to Professional. She also fiddles with way too many kernels and Linux distros.
- 1Linux Top 3: Network Security Toolkit, Untangle NG Firewall and IPFire
- 2Linux Top 3: Fedora 24, Peppermint 7 and Solus 1.2
- 3Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 4Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 5Linux 4.6 Charred Weasel adds USB 3.1 Support