How computer boots series - Part 1d: Init Process
Welcome! You are about to start on a journey to learn about booting process in different operating systems. For your reference, below is a list of the articles in this series:
- Part 1a: Linux - BIOS and Master Boot Record
- Part 1b: Linux - The Bootloader
- Part 1c: Linux - the Kernel and Initial Ramdisk
- Part 1d: Linux - Init Process (this article)
In this post, we continue Linux boot process with the Init Process whose responsibility is to run start-up scripts.
Init checks the runlevel mode by reading the configuration file such as /etc/inittab.
In single-user mode, only a minimal set of filesystems is mounted, no services are running, and a root shell is started on the console. Init forks off a process that executes the shell and waits for this process to exit.
If runlevel is in multiuser mode, the init process forks off child process to executes the start-up scripts, i.e. /etc/rc*.d or /etc/init.d, which can do file system consistency checks, mount additional file systems, start daemon processes, etc. Then it reads /etc/ttys to lists the terminals. For each enabled terminal, it forks off a copy to executes program getty to displays the login screen:
When a user provides a login name, getty terminates by executing /bin/login - the login program to ask for a password, encrypts it, and verifies it against the encrypted password stored in the password file, /etc/passwd. If it is correct, login replaces itself with the user’s shell, which then waits for the first command. Otherwise, login just asks for reentering.
The messages from the user-space startup procedures are often not generated in single log file, as the startup scripts usually print the messages to the console and they’re erased after the boot process finishes. However, each script typically writes its own log. Some versions of init, such as Upstart and systemd, can capture diagnostic messages from startup and runtime that would normally go to the console.
In a Linux desktop system, the X Window System is loaded as the final step in the boot process. A service (display manager) keeps track of the displays being provided, and loads the X server. The display manager also handles graphical logins, and starts the appropriate desktop environment after a user logs in.
After a user has logged in, he can start to interact with the system or communicate with other systems.
Leave a comment