Bootstrapping in Linux

Linux kernel itself is a program and the first bootstrapping task is to get this program into the memory so that it can be executed. Linux implements a two stage booting process. During the first stage, the system ROM loads a small boot program into the memory from the disk which in turn loads the kernel. Then, the kernel performs the memory tests to find out how much RAM is available. Some of the kernel’s internal data structures are statically sized, so the kernel sets aside a fixed amount of real memory for itself when it starts which is used only by the kernel [Kernel space](Correct me if I am wrong..) and the users cannot use it. Then the kernel prints on the console the total amount of physical memory and the amount available for the user processes.

One of the kernel’s first task is to check out the hardwares connected to it. When you design a kernel, you have to inform it which drivers are to be found and it will find them and prints a criptic information of each of the devices on the console. The kernel probes the bus and try to locate the drivers, if not found, they are disabled and are enabled when found afterwards.Then, after the basic initialization, the kernel creates several spontaneous processes (as they are not created using fork()). init() [PID 1] is accompanied by several kernel and memory handling processes like kflushd, kupdate, kpiod, kswapd. Of these, only init() is a full-fledged process, others are part of the kernel that have been dressed up to look like processes for scheduling and architectural reasons .

Once the spontaneous processes have been created, then we can say that bootstrapping is complete. The remaining processes that handle other operations are started by init().

To enter into single-user mode, we have notify init() by setting a command-line flag. init() eventually turns the control over to sulogin, and prompts for password. You can continue wih the multi-user mode by pressing Ctrl-D. A shell appears in the single-user mode, where we can use all the commands used in the multi-user mode. Usually, most of the daemons wont run in the single-user mode. We have to manually mount the filesystems that are not in /bin, /sbin, /etc.

The fsck command is normally run during an automatic boot to check and repair filesystems. In the single-user mode, you need to run the fsck commannd by hand. When the single-user mode exists, the system will attempt to boot into multi-user mode.

Finally, many of the start-up scripts are called by init(). getty is called as the last process by init(), using which we can login to the system.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: