Labels

Sunday, 21 May 2017

How linux boots from bios?

Linux Boot Process

When a PC is booted it starts running the BIOS program. This is a memory resident program usually residing on an EEPROM integrated circuit. Usually the user is allowed to set up the boot process with the BIOS firmware. For example boot priorities might be set to attempt boot first on Drive A (floppy) then Drive C (hard disk) then CDROM. The first sector on the booting media is then read by the bios program. The boot sector contains a small program which is run at this time. This program has the task of reading the operating system from the disk and running it. LILO is the program that Linux systems typically use to allow users to have a choice of operating systems to boot from. It is usually installed in the boot sector (also called the master boot record). If the user chooses to boot Linux, LILO will load the Linux kernel into memory and roughly the following happens:
  • LILO will read the file "/etc/lilo.conf". LILO will give the user a choice of booting from any label included in this file. If booting into Linux, there should be a line like "root=/dev/hda5" indicating what device will be mounted as root. There will also be a line like "image=/boot/vmlinuz-2.2.5-15", telling what kernel image to load.
  • The Linux kernel is installed compressed, so it will first uncompress itself. The beginning of the kernel image contains a small program that does this.
  • If you have a super-VGA card that Linux recognizes and that has some special text modes (such as 100 columns by 40 rows), Linux asks you which mode you want to use. During the kernel compilation, it is possible to preset a video mode, so that this is never asked. This can also be done with LILO or rdev.
  • After this, the kernel checks what other hardware there is (hard disks, floppies, network adapters, etc), and configures some of its device drivers appropriately; while it does this, it outputs messages about its findings. 
  • Then the kernel will try to mount the root filesystem. The place is configurable at compilation time, or any time with rdev or LILO. The filesystem type is detected automatically. If the mounting of the root filesystem fails, for example because you didn't remember to include the corresponding filesystem driver in the kernel, the kernel panics and halts the system (there isn't much it can do, anyway). The root filesystem is usually mounted read-only (this can be set in the same way as the place). This makes it possible to check the filesystem while it is mounted; it is not a good idea to check a filesystem that is mounted read-write.
  • After this the kernel starts the program "init" (located in /sbin/init) in the background (This will always become process number 1). Init will start the services setup in the system. This document is written to explicitly analyze the methods used for init to bring system services up. This should enable the reader to better understand how the system is set up and operates.

 

No comments:

Post a Comment