0% found this document useful (0 votes)
36 views8 pages

Linux Booting

The document provides an overview of the kernel and BIOS, detailing their roles in managing computer operations and hardware interactions during the boot process. It explains the Master Boot Record (MBR) and the stages of the boot loader, including GRUB, which loads the operating system kernel into memory. Additionally, it outlines the kernel's responsibilities and the transition to systemd for managing system services after the kernel is loaded.

Uploaded by

jatinbajpai1993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views8 pages

Linux Booting

The document provides an overview of the kernel and BIOS, detailing their roles in managing computer operations and hardware interactions during the boot process. It explains the Master Boot Record (MBR) and the stages of the boot loader, including GRUB, which loads the operating system kernel into memory. Additionally, it outlines the kernel's responsibilities and the transition to systemd for managing system services after the kernel is loaded.

Uploaded by

jatinbajpai1993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Note-

A kernel is the central part of an operating system. It manages the operations of the computer and
the hardware, most notably memory and CPU time.[1]

The kernel is a computer program at the core of a computer's operating system that has complete
control over everything in the system. It is the "portion of the operating system code that is always
resident in memory", and facilitates interactions between hardware and software components

The Kernel is responsible for low-level tasks such as disk management, memory management,
task management, etc When the computer starts, it goes through some initialization (booting)
functions, such as checking memory. It is responsible for assigning and unassigning memory space
which allows software to run.

BIOS

 BIOS stands for Basic Input/Output System.


 BIOS are low-level software (coded in assembly language) that
 BIOS is a pre-installed firmware on a system/server’s Mother board.
 Performs some system integrity checks over the HDD
 BIOS is POST (Power On Self Test). It’s a hardware self test. POST tests are
simple read/write tests of a few location.
 Searches, loads, and executes the boot loader program , mostly in the
Master Boot Record (MBR)
 It looks for boot loader in floppy, cd-rom, or hard drive. We can press a key
(typically F12 of F2, but it depends on your system) during the BIOS startup to
change the boot sequence.
 BIOS is stored in EEPROM
 Once the boot loader program is detected and loaded into the memory, BIOS
gives the control to it.
 So, in simple terms BIOS loads and executes the MBR boot loader

Step 1. BIOS (Basic Input Output System)


Both UEFI and BIOS are low-level software (coded in assembly language) that starts when you
boot your PC before booting your operating system, but UEFI is a more modern solution, supporting
larger hard drives, faster boot times, more security features, and—conveniently—graphics and
mouse cursors.
BIOS is a pre-installed firmware on a system/server’s Mother board. BIOS controls the
computer hardware. BIOS is used to perform hardware initialization during the booting process.
The main job assigned to BIOS is POST (Power On Self Test). It’s a hardware self test. POST
tests are simple read/write tests of a few location.
The POST tests are not much useful as a Hardware diagnostic test. It just test the system hardware
components, and loads a boot loader.
The main two errors occur during POST are:

1. Fatal error. This occurs due to hardware problems.


2. Non fatal error. Due to software problems.

Main responsibilities of BIOS during POST are listed below:

1. Verify CPU registers.


2. Verify the integrity of the BIOS code itself.
3. Verify some basic components like DMA, timer, interrupt controller.
4. Find, size, and verify system main memory.
5. Initialize BIOS
6. Identify, organize, and select which devices are available for booting.

The beep sound after the POST indicate its result.


A short beep while restart/start means normal POST – system is OK.
Two short beeps means POST error – error code shown on screen and so on. Check POST
manual for more details.
BIOS act as an intermediary between computer CPU and Input/Output devices. This eliminates
the need for the operating system and software on the system/server are always aware about the
details of hardware and other I/O devices. If any harddisks or I/O devices changed, only the BIOS
needs to be updated.
BIOS is stored in EEPROM (Electrically Erasable Programmable ROM) / Flash memory. BIOS can
not stored on a hard disk or other devices, because it manages those devices.
BIOS is written in assembly language.

Step 2. Stage 1 boot loader (MBR)

MBR
 MBR stands for Master Boot Record.
 MBR contains both program code and partition table details.
 It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda
 MBR is less than 512 bytes in size. This has three components
 1) primary boot loader info in 1st 446 bytes
 2) partition table info in next 64 bytes
 3) mbr validation check in last 2 bytes.
 It contains information about GRUB (or LILO in old systems).
 So, in simple terms MBR loads and executes the GRUB boot loader.

Master Boot Record, is the first place where boot loaders begins to start. MBR is a 512 byte sector
located in the first sector of hard disk. MBR contains both program code and partition table details.
Please see the image added below:

When allocating disk space for a partition, the first sector or data unit for each partition is always
reserved for programmable code used in booting process. The very first sector of the hard disk is
reserved for same purpose and it’s called the Master Boot Record. In case of a mechanical
spinning disk, sector 1 of cylinder 0, head 0.

First 446 byte are the primary boot loader which contains both executable code and error message
text.
Next 64 bytes contains the partition table. This section contains records for each of four partitions. In
the above image P1 represents Partition 1, P2 for Partition 2 and so on.
4 x 16 bytes = 64 bytes
The last two bytes known as magic number (0xAA55). This number is used for the validation check
of MBR.
When booting from a hard disk, the BIOS starts by loading and executing boot loader code. The
MBR size is not enough sometimes to execute the complete boot loader code. Because, its size is
larger than the available space in MBR. So booting has to be done in different stages. These stages
are different in different boot loader on your system. Yeah, it’s time to move over to Stage 2 boot
loader
NOTE: Now MBR directly cannot load the kernel as it is unaware of the filesystem concept and
requires a boot loader with file system driver for each supported file systems, so that they can
be understood and accessed by the boot loader itself.

GRUB2 stands for "GRand Unified Bootloader, version 2"


loads kernel into memory
1) GRUB2 is the program which makes the computer just smart
enough to find the operating system kernel and load it into
memory.
2) GRUB2 has been designed to be compatible with the multiboot
specification which allows GRUB2 to boot many versions of
Linux and other free operating systems;
3) GRUB can also allow the user to choose to boot from among
several different kernels for any given Linux distribution.

GRUB stage 1: /Bootstrap code

 The primary boot loader takes up less than 512 bytes of disk space in the MBR - too
small a space to contain the instructions necessary to load a complex operating system.

 The total amount of space allocated for the actual bootstrap code in
a classic generic MBR is 446 bytes. The 446 Byte file for stage 1 is named
boot.img and does not contain the partition table which is added to the boot
record separately.
 Instead the primary boot loader performs the function of loading either the stage 1.5 or
stage 2 boot loader.

GRUB Stage 1.5:

 Stage 1 can load the stage 2 directly, but it is normally set up to load the stage 1.5.

 This can happen when the /boot partition is situated beyond the 1024 cylinder head of
the hard drive.

 GRUB Stage 1.5 is located in the first 30 KB of Hard Disk immediately after MBR and
before the first partition.

 This space is utilized to store file system drivers such as the standard EXT and
other Linux filesystems, FAT, and NTFS. and modules.(mounting is done by
system)IMPORTANT

 This enabled stage 1.5 to load stage 2 to load from any known location on the file
system i.e. /boot/grub

GRUB Stage 2:

 This is responsible for loading kernel from /boot/grub/grub.conf and any other
modules needed
 Loads a GUI interface i.e. splash image located at /grub/splash.xpm.gz with list of
available kernels where you can manually select the kernel or else after the default
timeout value the selected kernel will boot

The original file is /etc/grub.conf of which you can observe a symlink file
at /boot/grub/grub.conf

Sample /boot/grub/grub.conf
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-194.26.1.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.26.1.el5 ro root=/dev/VolGroup00/root
clocksource=acpi_pm divisor=10
initrd /initrd-2.6.18-194.26.1.el5.img
title Red Hat Enterprise Linux Server (2.6.18-194.11.4.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.11.4.el5 ro root=/dev/VolGroup00/root
clocksource=acpi_pm divisor=10
initrd /initrd-2.6.18-194.11.4.el5.img
title Red Hat Enterprise Linux Server (2.6.18-194.11.3.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-194.11.3.el5 ro root=/dev/VolGroup00/root
clocksource=acpi_pm divisor=10
initrd /initrd-2.6.18-194.11.3.el5.img

Kernel
This can be considered the heart of operating system responsible for handling all system processes.

All of the kernels are in a self-extracting, compressed format to save space.


The kernels are located in the /boot directory, along with an initial RAM disk
image, and device maps of the hard drives.

After the selected kernel is loaded into memory and begins executing, it must
first extract itself from the compressed version of the file before it can perform
any useful work. Once the kernel has extracted itself, it loads systemd, which
is the replacement for the old SysV init program, and turns control over to it.

Kernel is loaded in the following stages:


An image file containing the basic root file system with all kernel modules are then loaded into the
memory. This image file is located under /boot and it’s known as initramfs.
Initramfs, abbreviated from “initial RAM file system”, is the successor of initrd “initial ramdisk”

1. Kernel as soon as it is loaded configures hardware and memory allocated to the system.

2. Next it uncompresses the Initramfs image (compressed using zlib into zImage or bzImage
formats) and mounts it and loads all the necessary drivers.

3. Loading and unloading of kernel modules is done with the help of programs like insmod, and
rmmod present in the initrd image.
4. Looks out for hard disk types be it a LVM or RAID.

5. Unmounts initrd image and frees up all the memory occupied by the disk image.
6. Then kernel mounts the root partition as specified in grub.conf as read-only.
7. Next it runs the SYSTEMD (REPLACMENT OF init ) process

systemd

systemd is the mother of all processes and it is responsible for bringing the
Linux host up to a state in which productive work can be done

Some of its functions, which are far more extensive than the old init program,
are to manage many aspects of a running Linux host, including

Starting and managing system services required to have a productive Linux


host.

First, systemd mounts the filesystems as defined by /etc/fstab, including


any swap files or partitions.

NOTE:-

RAID (Redundant Array of Inexpensive Disks[1] or Drives, or Redundant Array of Independent


Disks) is a data storage virtualization technology that combines multiple physical disk
drive components into one or more logical units for the purposes of data redundancy, performance
improvement, or both. This was in contrast to the previous concept of highly reliable mainframe disk
drives referred to as "single large expensive disk" (SLED).[2][3]
Data is distributed across the drives in one of several ways, referred to as RAID levels, depending
on the required level of redundancy and performance. The different schemes, or data distribution
layouts, are named by the word "RAID" followed by a number, for example RAID 0 or RAID 1. Each
scheme, or RAID level, provides a different balance among the key
goals: reliability, availability, performance, and capacity. RAID levels greater than RAID 0 provide
protection against unrecoverable sector read errors, as well as against failures of whole physical
drives.

You might also like