Difference between GRUB and GRUB 2, LILO and GRUB


Difference between Grub and Grub 2:
GRUB
GRUB 2
Grub has two configuration file which is menu.lst and grub.conf.
Grub 2 has only one configuration file which is grub.cfg.
Grub configuration file is difficult to modify.
Grub 2 configuration file is easy to modify, with the help of grub-mkconfig command which automatically changes the configuration. 
Grub partition number starts from 0
Grub 2 partition number starts from 1
Grub uses logical block addressing mode (LBA) to identify files and partition.
Grub 2 uses UUID to identify the files and partition which is more reliable.
Grub configuration file is in a different format.
Grub 2 configuration is very close to a full scripting language.
Grub can read from many partitions but not from newer partitions like LVM and RAID.
Grub 2 supports LVM and RAID devices.

Difference between Grub and LILO:
GRUB
LILO
Grub stands for GRAND UNIFIED BOOT LOADER.
LILO stands for Linux loader.
Grub support for unlimited boot entries.
LILO only supports up to 16 different boot selection.
Grub can boot from the network.
LILO cannot boot from the network.
There is no need to change a Grub if configuration file changed, Grub is dynamically configurable.
There is a need to change a LILO if the configuration file is changed, LILO is not dynamically configurable.
GRUB has an interactive command interface.
LILO does not have an interactive command interface.
Grub has knowledge of the file system.
LILO does not have knowledge of the file system.

Grub boot process:
Grub need to load itself into the memory for the boot process and this is done in the steps are given below:

Stage 1: In stage 1 grub boot loader is loaded into the memory by the BIOS. The grub boot loader is known as primary boot loader and it exists on 512 bytes or less of the disk space within the master boot record. If required the primary boot loader can load the stage 1.5 or in stage 2.

Stage 1.5: This stapes may be necessary for some cases as some hardware required a middle step before moving to the stage 2.

Stage 2: The stage 2 boot loader can be loaded into the memory by the primary boot loader and it is also known as secondary boot loader. Stage 2 boot loader performs some functions like display of grub menu and command environment. The kernel is loaded into the memory by the stage 2 or secondary boot loader after that the control of the machine is transferred to the operating system  

Linux Boot Process


The boot process is the series of steps taken by the operating system to be ready for user input. As a system administrator, it is important to know about the steps and the processes in every step while the machine boots up.


BIOS: BIOS is the lower-level software which is the first thing that loads once you power-on your machine. It is a pre-installed firmware on systems or on a server’s motherboard. It stands for Basic Input /Output System. When BIOS boots up (startup) it first performs hardware initialization. BIOS is stored in an Electrically Erasable and Programmable ROM (EEPROM) or on a non-volatile ROM chip on the motherboard and in modern computer systems, the BIOS is stored in a flash memory chip.
When the pc is powered on the BIOS runs the POST (Power on Self-Test). The main job of POST is to ensure that the computer hardware functioned correctly. Basically, it does the diagnostic test on the hardware for some errors on the hardware component and there are two main errors that occur during POST are fatal error, which occurs because of hardware problems and non-fatal error, which occurs because of software problems.  If the POST fails the boot process does not continue.
 After finishing all the task BIOS then executes the MBR boot loader.

Master boot record (MBR): It is located in the first sector on the hard drive along with the partition table. It is very small because it must fit into the first sector and it is 512 bytes in size which is not part of any partition. The MBR contains an important bit of code called a bootstrap code.
While allocating disk space for partition the first sector or data unit always reserve programmable code for each partition in the booting process. MBR contains information about boot loaders such as (GRUB, LILO, NTLDR, BOOTMGR, or GRUB2). In the hard disk, the primary sector of the first cylinder of the track is 0 and the head is 0.
In the 512 bytes size, it has three components, first 446 bytes for primary boot loader which contains executable code and error message text, second 64 bytes for partition tables and in this section, it contains records for each four partition for example partition 1 with 16 bytes so, 4 partition x 16 bytes is 64 bytes and the last component of 2 bytes is for validation check.
In the booting process after loading MBR, the next step is to execute the Grub boot loader.

Grub:  Grub is developed by GNU under the GNU project. There are two types of boot loader for Linux which is LILO and GRUB. The main difference between the LILO and GRUB is LILO did not understand file systems and GRUB has the knowledge of the file systems means GRUB can load the kernel from ext2, ext3, ext4, VFAT, xfs file system. The LILO stands for Linux Loader and GRUB stands for Grand Unified Boot Loader. LILO was the first release in 1992 and GRUB 1 was first released in 1995 and the latest is GRUB 2 which was released in 2019
GRUB is located in the first sector of the bootable disk. GRUB is a boot loader program which loaded into RAM, then it searches for the kernel location. GRUB supports both BIOS and UEFI and if you have multiple images of the kernel installed on your system, you can choose which one you want to be executed, by default only the major one boots up.
The GRUB displays the GRUB menu on the monitor for few seconds and allows you to select the kernel you want to run if you don’t select anything it loads the default kernel image which specified in the GRUB configuration file. The configuration file of the GRUB is in /boot/grub/grub.conf or /boot/grub2/grub.cfg.

Kernel: The kernel stage begins in a compressed format to save space. It located in the /boot directory along with initrd (initial RAM disk).
After the selected kernel loads into memory and starts executing, it first extracts itself from the compressed format of the file before it can perform any work. Once the kernel extracts itself, it starts loads systemd which is the replacement of the old init program.
The system is the very first process that loads all the various daemons and mounts all the partition which are listed under the /etc/fstab file.

Systemd: The Systemd is a system and service manager daemon. A daemon is a Linux program that runs as a background process and all daemons have name ends with the letter “d”. The kernel starts the system process with process ID no 1 (PID 1). Systmd is the first process that starts after system boots and it is the last process that is running when the system shuts down. It controls the final stages of booting and it speeds up the booting by loading services concurrently.
Systemd prepares the system for use and it provides a logging daemon and other utilities to help with common system administration tasks. Some of the functions of the system are more powerful than the init program which use to manage many aspects of a running Linux system. Systemd is a default init system for some major Linux distributions along with backward compatible with SysV init script. It was intended to overcome the shortcomings of the init program.
Systemd reads the linked file from /etc/systemd/system/default.target.wants or in some Linux distribution /etc/system/system/default.target to determine the default target which is equivalent to run level. The system target file defines what services the system is running. In init systems run levels are identified by the numbers and in systemd run levels are referred to a target.

Comparison of Run Levels and Target Units:
Run level
Target
Description
Run level 0
Poweroff.target
To Halt / Shutdown the system
Run level 1
Rescue.target
To start in a single user mode for troubleshooting
Run level 2
Multi-user.target
Start system with multi-user mode but without network
Run level 3
Multi-user.target
Start system with multi-user mode with network
Run level 4
Multi-user.target
User-definable
Run level 5
Graphical.target
Start system with multi-user mode with GUI (Graphical user interface)

Run level 6
Reboot.target
The reboot which is used to restart the system

Systemd allows you to manage different types of units on the system such as services “name.service” and targets “name.target” and etc.

Featured Post

Managing user and groups, UID and GID in Linux

What are users in the operating system? A user is a person who accesses or utilizes computer resources or network services. In order to ...

Popular Posts