Booting a Linux computer
BIOS
GRUB (GRand Unified Bootloader)
Modifying GRUB during startup
Editing the grub.conf file
BIOS - This has nothing to do with the Linux boot process because it does the same for any other OS. The BIOS software is stored on a ROM chip on the motherboard. When power is first applied to the computer it runs the POST (Power On Self Test) which is part of the BIOS (Basic I/O System). The boot sector is really the first stage of the boot loader. There are three boot loaders used by most Linux distributions, GRUB, GRUB2, and LILO. GRUB2 is the newest and is used much more frequently these days than the other older options.
GRUB (2 Stages): After the BIOS test, the next stage is to find the boot sector of the first bootable drive. And, in this case, it looks for the 512 bytes, and what it find there is GRUB.
Stage 1: The first stage is to find Master Boot Record (MBR). The size of the MBR is just 512 bytes. GRUB where it gets initialized.
Stage 2: After the initializing the GRUB, the function of GRUB at stage 2 is to locate and load a Linux kernel into RAM and turn control of the computer over to the kernel. The kernel and its associated files are located in the /boot directory. Once the kernel is loaded correctly, the system is handed over to a process called init.
INIT: The actual process that starts to which we can interact with. In the latest version of Linux, the init process is replaced by systemd. Though init file is still located at /sbin/init
but it simply point to /lib/systemd/systemd
From here you can go into different runlevels to rescue the environment and also do some hacky things:-) You can press e
for edit.
Notice I have added 1 to go into the runlevel 1 which is a configuration mode. This is the same as going into the safe mode in Windows.
If something has gone really horrible, you want to into init=/bin/bash
mode before anything program starts up. This is as lowest as you can go.
What is a runlevel and how is it used?
How to switch between runlevels?
Changing the default runlevel
​
0 - Halt (shutdown)
1 - single user mode
2 - multi user mode - no networking
3 - multi user w/networking (server)
4 unused
5 - multi user w/networking (GUI)
6 - reboot
Example: Checking the runlevel and going to runlevel 3.
You can get out here by typing in startx
that will take you to the GUI again but it will still remain at runlevel 3.
You can check the init or systemd process by pstree
:
These different scripts corrospond to different runlevels. They either start or stop things: