Linux Foundation LFCS – Domain No. 2 – Operation of running system

  1. Boot process

Hello and welcome again, students. This is the beginning of our domain two of the LFCs certification course, and the first item that we’re going to pick in it is the Linux boot process. So let’s start on that. So it is important to understand the Linux boot process to troubleshoot boot problems. These are high level steps in the boot process. You need to be aware of files involved in the boot process because errors in these files can cause boot problems. If there’s an issue during boot, you need to identify in which phase of boot process the issue lies so that you can take appropriate actions to fix the issue. System.

D is the new system and service manager in Sentos and Red Hat Seven. It is backward compatible with System Five init scripts used by previous versions of Red Hat Linux, including Ralph Six. It replaces Upstart as the default initialization system. So, looking at this graphic, the following steps summarize how the boot process happens in a Red Hat system or a Centau system. First, the computer BIOS perform the post. Then the BIOS reads the MBR for the bootloader. Then in the third step, the Grub Two bootloader loads the VM Linus kernel image.

Then the Grub Two extract the contents of the intra MFS image. In the fifth step, the kernel loads driver modules from the init RMFS. And in the 6th step kernel starts the system first process system D. The system D process takes over and then it reads configuration files from the Etsy system d directory, reads the linked file linked by Etsy systemd system default directory or default target and brings the system to the state defined by the system target and then finally execute etc. RC local.

So, starting with the Post or Power on Self test from the system firmware, which can be the modern Universal Extended Firmware interface, also called UEFI or the Classical Basic Input Output System, which is called BIOS, the Power on Self test or Post is executed and the hardware that is required to start the system is initialized.

In the next step, the Master boot Record or MBR, which is the first 512 bytes of the boot drive I e. Your hard drive is read into memory by the BIOS. The next 64 bytes, which are right here, the partition table contains a partition table for the disk and the last two bytes, they’re also called the Magic Number, which is used for error detection. MBR discovers the bootable device and loads the Grub Two boot loader into memory and transfers control over to it.

So the next step in the boot process is loading the bootloader or Grub Two. The default bootloader program used on rail seven is grub two. Grub Two stands for grand Unified boot loader and replaces the older Grub bootloader, also called as Legacy Grub. So grub two configuration files located at bootgrub twogrub CFG. Let’s take a look at so let’s go to the bootgrub two.

And our file is called Grub CFG. So I’m going to do cat on grub CFG. It’s a very long file. So let’s do a pipe and less. This is a way if the screen, if the file is scrolling by and you cannot see all of it, you can do pipe it and then do a more RLS and then it’ll show you the rest of the file. Again, this file should not be edited directly, it automatically created. And unless if you really know what you’re doing, you should not be touching this file. I just wanted to show it to you what it looks like. And so this is how your default kernel or the Grub is configured. These are all different settings and we’ll go into this when we get to that section and I just press Q to get out. So Grub Two menu configuration settings are taken from the Etsy default Grub file. So let’s take a look at that cat etc. Default Grub. And this is much smaller file Grub timeout. You can change that over here.

If I were in, let’s actually do it to Etsy default Grub. And suppose I want to change the Grub timeout. This is the timeout that the screen was displaying the menu. So I’m going to press an R to replace it and I’m going to say nine. This is how you replace something in the VI editor. I just press R to replace it and then press number nine and then I’m going to escape colon WQ bang and I’m exited. So now I’ve changed that one perimeter.

Now anytime a change is made to the Grub CFG file, then you need to run Grub Two mkconfig to regenerate the Grub CFG. The way you do that is let’s clear this and then we’re going to run Grub Mkconfig o boot Grub Two, Grub CFG and it’s regenerating the Grub CFG file because we made one change in there. So Grub Two searches the compressed kernel image file, also called as VM linus in the slash boot directory. Then Grub Two loads the VM linus kernel image file into memory and extract the contents of the init Ram FS image file into a temporary memory based file system called Tmpfs, the initial Ram disk or init RDS initial root file system that is mounted before the real root file system init Ram FS.

The job of the initial Ram file system is to preload the block device in modules such as for IDE scuzzy or Raid, so that the root file system on which those modules normally reside can then be accessed and mounted. The init Ramfs is bound to the kernel and the kernel mounts. In it are Ram FS as part of a two h stage boot process. The LS init RDLs command is going to view the contents of the image created by the Gracket utilities and I’ll show you what it looked like. LS init rd less. This is your kernel architecture. And this is what’s called the Init Ramfs. And it’s created by a file called Dracut. Bracket. And so when you use the LS init Rd command to view the contents of the image that are created by this utility called Bracket.

 

  1. Boot process continues

Okay, so we’re going to continue with the boot process in this lecture as well. So I’m going to show you how to backup the master boot record or MBR first. So let’s start off with Ddif. Dev SDA is the first disk on my system. It might be something different on yours, but mine isdefsda off equals MBR masterboot record BKP. That’s what we’re going to name it. Backup and BS equals five, one, two and count equals one. Okay, it’s copied. If you do an LS at this point you’ll see an MBR BKP file that is copied. So this is a good practice. If you’re going to change or edit the MBR or the master boot record then it’s a good idea to have a backup copy of it if you have to restore it off of it the command that you run. I’m going to do an up arrow to bring the history. This is the history. This is a very neat feature of Linux. If I haven’t mentioned before. You just bring the up arrow and down arrow.

It’ll tell you what commands you have run so far. So I’m going to bring this up and I’m going to change and delete this. If equals MBR BKP which we already have. And then you’re going to go off equalsdevsda and the rest of the information remains the same. So if you look at the previous command we have just reversed. That means right here on the top we have just reversed of what we did before. So that way we’re back comes our current MBR and there you go. It’s copied to its original MBR now. So once the real root file system is up, the kernel executes the system and service manager. And depending on your system it could be in it process or the system D process.

And their process ID is always going to be one. And the way you can check that is do a Pspid for process ID and type one. And as you can see on my system is system D that has the process ID of one. Now Linux system can be running at any given time in six different run levels. How can you tell which run level you are in right now? You do a who dash R. I am in run level three. Currently Linux have run level from zero through six. So actually it’s seven different run levels. But zero is the halt system. Run level zero is special transitional state used to shut down the system quickly. Okay. One is also alias to S or capital S. This run level is sometimes called maintenance mode. What services, if any are started at this run level varies by distribution. It’s typically used for low level system maintenance that may be impaired by normal system operation. Run level two is multiuser on Divian systems and derivatives.

This is the default run level and includes if available at graphic login on Redhead based systems. This is multi user mode without networking. Run level number three on Redhead based systems. This is the default multi user mode which runs everything except the graphical environment. As you can see in my case, I’m running everything except the graphical environment. This run level and level four and five are usually not used in Davian based systems. Four typically unused by default and therefore available for customization. And run level five on red Hat based systems is full multi user mode with GUI login. This run level is like level three, but with a Gui login available. And run level six is the reboot. The run level file is the Etsy init tab file. So if you go to Etsy and do LS init tab, you see a file there and if I VI it, R actually cat it init tab. This is where our in my case is run level three. And this is where it is mentioned that it’s going to run as run level three.

But in run level three is by default run level three. So as you can see in this message here, system D uses target instead of run levels. By default there are two main targets multi user target analogous to level three and graphical target analogous to run level five. So this is how things used to get done. You will change the init tab file, it’ll be showing run level three or five or whatever you are running in and then you would go in and actually change it in there. So once we get to this point, then the run level actually kicks off a script and the script is going to be dependent on which run level you are in. What I mean by that is so the run level could be from zero through six, as I mentioned earlier.

And if I run this command LSL etc. And then grip for RC zero through six D, it gives me all these directories, as you can see RC zero, RC one all the way through RC six D and they are linked to these other files. So in our case, since we are located, let me clear it so we can go on top of the screen. In our case we are in Slash etc. And if we go to CD two, RC 3D, if you do a Pwdut, we are in Etsy, RC three D. And if you do an LS here, these are the scripts that can get triggered at the time of booting the system.

It’s also a very important interview question and it’ll probably come up in the test as well. That what system starts at, the boot process. So depending on the run level you’re in, if you’re in RC 3D, these are the default scripts that get kicked off at the time of boot. And if I do an Lsal, you can see that all of these are linked. This is the Rhnsd network and net console. These are all soft links that are associated with these scripts and anything else custom that you want to create and put it in this directory. RC 3D it’s also going to get kicked off at the same time when the rest of the scripts get started.

img