...

Monday, February 22, 2010

Debian 3

When Debian boots up, it follows a few predefined steps before control is given to the user. The first thing it runs, is BIOS, which stands for Basic Input/Output System. It initiates the POST (Power On Self-Test) which checks for hardware (RAM, CPU, Storage, Keyboard, Removable Storage, etc). Each computer architecture has their own hardware check routine (which may not be called BIOS).
After the hardware is checked, BIOS initiates the MBR on the default storage device. Recall that GRUB is installed in the MBR. GRUB stands for Grand Unified Boot Loader, which is designed to take over LILO. GRUB allows to boot into Multi-User or Single-User modes. Multi-User is the default, while Single-User is typically used for administrative purposes.

GRUB also allows interaction with the boot process. You can pass parameters into the kernel from the GRUB menu. GRUB is also used by SUSE and RedHat. GRUB then initiates the INITRD (Initial RAM Disk) which loads key drivers to support storage and other sub-systems. The MBR can only contain 512 bytes of data, so GRUB is split into multiple phases. The 512 byte code is the bootstrap, which loads the other components stored elsewhere.

The RAM Disk is temporary. After complete initiation of drivers, the kernel would have access to the '/' root file system. At this point the INIT process takes over, which sets up the system to the desired run-level. The run-level consists of killing and starting several services (klogd, syslogd, network services and other applications). INIT has the PID of 1, and is the parent of all processes. INIT is called by Scheduler, which has the PID of 0.

To view processes, you can use:
ps -aux
ps -ef


The above-described process is shared by most Linux systems. The main steps are: BIOS > GRUB > INITRD > INIT.

The Linux kernel is stored in /boot/. In the same folder, you'll also find the initrd.img image and the initrd application. In /boot/, we can also find the ./grub/ folder which houses various menu items and scripts. In there, you can find the menu.lst which stores information similar to what you see in Windows bcedit.

In menu.lst, and many other parts of Linux, you will see hard disks specified in the form (hdx,y). x stands for the hard drive number, which starts from 0. y stands for the partition number, which also starts from 0. From menu.lst, you can also see the kernel and the initrd image that is used. You can see that the "single" parameter is passed into the kernel to boot into Single-User mode.

The files in /boot/grub/ shows the process of booting from GRUB. stage1 is exactly 512 bytes, which is the 512 bytes in the MBR. stage1_5 initializes the filesystem. Do note that there is no e3fs for stage1_5, because e3fs is essentially e2fs with journaling turned on. stage2 is considerably larger, which continues the bootstrap process.

In /boot/, there is a config file. If we "less" the config file, we can see the kernel options enabled during compilation. When we do a ls -l, we can see that vmlinuz and initrd are both linked from the '/' of the file system. This is to allow the boot loader to find the file initially.

When the INIT runs, it looks up a table known as the inittab. inittab is found in /etc/. When we "less" inittab, you can see that the default runlevle is 2. From inittab, we can also see that the rcS script in /etc/init.d/ is always executed regardless of the runlevel.

Runlevel 0 is runs scripts to shut down services. This is known as the halt runlevel. Runlevel 1 is for Single-User, which doesn't have networking for other users to connect. Runlevel 2-5 is for Multi-User mode. Runlevel 6 is for rebooting.

When CTRL+ALT+DEL is pressed, the system is rebooted. This is done by calling:
/sbin/shutdown -t1 -a -r now

INIT is also responsible for respawning ttys when they fail.

No comments :

Post a Comment

<