Everything About Linux -1
Linux Kernel & Boot Concepts
Linux Kernel acts as an interface between the computer hardware like CPU, memory, devices, and the applications /processes. It works efficiently to manage some of the kernel properties.
Functions of Linux Kernel-
- Memory Management — Kernel takes care of which process has taken how much of memory and where and in this way it helps in managing the memory.
- Process Management — It determines which process can use the CPU and for how long it can use it?
- Device Drivers — It acts as an interpreter or a mediator between the hardware and the processes.
- System Calls and Security — It receives requests from the processes known as a system call and completes the security processes to clarify there is no such vulnerates in-between.
Some of the main features of the kernel are
- Monolithic — Monolithic simply means, the kernel manages memory management, CPU scheduling, process management of their own.
- Modular — Modular simply means it can extend its capacities by dynamically loaded of their kernel and using that to work as per requirement more efficiently.
Once your PC has been powered on, the BIOS begins its work as part of the POST (Power-On Self Test) process.
After booting up the computer the first thing we see is
- BOIS- Basic Input Output System
- UEFI- Unified Extensible Firmware Interface
BIOS & UEFI are two different system interfaces but as an end-user, they both are the same but have a different process running inside the hood, Both ways are used to interact with Hardware and operating system.
Bios is one of the old ways of booting a system in which we divide the hard drive into 4 equal partitions and the boot process starts from 1st place with (MBR)- Master Boot Record that contains all the records.
Limitations With Bios
- You can only have 4 partitions of the drive using Bios & MBR combinations (some hacks to overcome this)
- Size of MBR(How much MBR can reference in terms of size).
That's where the Replacement UEFI comes
- Besides creating separate equal partitioning, it creates a special participation one only that stores code and works fast as well.
- UEFI provides secure Boot also whereas Bios doesn't provide.
After this process, the screen comes to the Bootloaders
A Bootloader is a critical piece of software that is responsible for loading the Linux kernel and Linux initial Ramdisk. Linux users can choose from Several different boot loaders, each with its strengths & weakness.
Different Bootloaders are-
- Grand Unified Bootloader (GRUB)
Most of the system contains Grub & Grub2 but sometimes you can confuse between those two because they both work similarly and have some minor changes.
Commands to customize Boot loader-
- Open the Grub file & edit it in nano accordingly ( nano /etc/default/grub)
- after Editing the file (Sudo Update-grub).
- To see the Grub2 file (Cd /boot/grub/ — ls- Output- Grub.cfg)
Linux Boot Methods
There are some amazing ways to Boot-Up your machine in a more power-efficient environment that you must know-
- PXE- (Pre-Boot Execution Environment)- Before Linux introduces to a system, the system comes across BIOS or UEFI, and under the same environment, PXE works. In the PXE Boot process when the system sees no drive, it queries the network i.e. is a DHCP Server and DHCP Server responds with IP Address and a boot file, and a TFTP Server(where it stores files on a network) & then system downloads that images from TFTP server & Here comes Linux in action loading kernel and finally it boots up.
- USB, CD & Hard-drive- It is quite easy to boot from these.
- IPXE- (Advanced Version of PXE)- It is almost the same as PXE but the only difference is it uses HTTP to download boot files from the server which is fast & reliable too.
- ISO- You can make a Grub2 entry and directly boot from the ISO even if you haven’t burned it to a disk or USB drive. In Boot-Process, first, it loads up the entire Linux & Grub then goes to ISO where we can select Kernel, Mentest, and much more.
The most Awesome way to BootUp is by using PXE which directly interacts with the server without any media interference.
How Does Boot Process Works?
- To successfully Boot-Up, Our kernel needs to mount all the modules that are currently mounted on the hard disk.
- When we switch on our system, BIOS or UEFI interacts with Hardware and then Grub comes into action.
- After that vmlinux comes into action that is just a basic structure of a kernel and now to make it a fully functional kernel, we need to mount all modules.
- But sometimes vmlinux fails to notice the location of modules now here comes “INITRD” i.e. is “ init-ram-disk” which is a temporary staging area that stores the address of modules and it redirects vmlinux to the address.
- “initrd” comes before vmlinux and it is not a part of vmlinux.
- While some people confuse initrd to initramfs that is a different thing. Init-ram-FileSystem manages the filesystem that is developed by Dracut. This is a part of vmlinux.
- vmlinuz is a compressed version of vmlinux that takes less space.
- cd /boot & ls- To find different files shown above.
- cd /lib/modules- To find Different files.
About The Author- Saurav Chaudhary
Saurav Chaudhary is an experienced Technical Content Writer. Bringing in a lot of knowledge about DevOps & Cloud, Blockchain, Web Development & Security. He strives to write pristine content about any IT-related subject.