In this course, you will learn how to install a Linux system and connect to it, whether that be on Mac or Windows.
Let's take a look at the Linux booting process. First, I'm going to enter the BIOS configuration utility. In this example, I can press F2 to enter the BIOS. This key combination varies from manufacturer to manufacturer. Most of the time there'll be a message displayed on the screen that tells you how to enter the BIOS configuration utility. If not, you'll have to consult the documentation for the hardware you're working with. I'll go ahead and click F2. The primary thing we are concerned with in the BIOS is the list of bootable devices. I'll go to the boot menu for this BIOS. This BIOS is configured to boot from removable devices first, then the hard drive and finally the CD-ROM drive, we can control the boot order.
In this BIOS I can make the server attempt to boot from the CD-ROM first by highlighting the CD-ROM and then pressing the plus key a couple of times to move it up the list. Once you've made your changes, you can go to the exit menu and exit the BIOS to continue booting. The BIOS now executes the boot loader from the first bootable device it can find. Here we're looking at the GRUB menu. If you have multiple operating systems installed this is where you can select the operating system to boot. This server only has CentOS installed and there are two menu entries to choose from.
In this example there are two Linux kernels installed on the system. Let's look at the first menu item by pressing the E key. The line that starts with Linux tells the boot loader which kernel to use, let's scroll down to find that line. Here it is. Anything that appears after the kernel is passed to the kernel as an argument on boot. Here you see the path to the kernel, which is /bootvmlinuz-the version.x86_64. Everything else on the command line there is passed to the kernel as an argument. This is where, if you wanted to boot the system into single user mode, you could supply an S-argument to the kernel, like so.
Let's first boot this system without changing anything though, we'll go ahead and click escape to get out of this menu and then simply hit enter to start this particular kernel. On boot up here you'll only see a couple of messages. Once that boots up, we'll reboot again and tell the kernel to give us more information during the boot process. Go ahead and log in here as root. And to reboot, remember that there are a couple of ways to do this. One is by using the shutdown command, you could do shutdown, dash, R, and give a time, such as now or five minutes from now, and then optionally a reboot message, a lot like this, for example, or you could simply run the reboot command which is what I'm going to do now.
Let's edit the menu item and we'll go in here on the kernel line and you'll notice this quiet option. The quiet option suppresses a lot of the log messages on boot, so we'll go ahead and remove this argument. And then as you can see at the bottom of the screen, you can press CTRL-X to boot this configuration so that's what we're going to do right now. I'll hit CTRL-X, and then now you can see a lot more messages scrolling past the screen.
Okay, we'll log into this system and look at those messages that just flew by. The D-message command displays the contents of the kernel ring buffer. So if we run that message again we see the messages we saw during boot this time, but these messages are just flying by so I'm going to pipe that output of D-message to a pager, I'll just use less. The numbers in the bracket represent time in seconds since boot, so if you want the actual time you could run D-M-E-S-G, space, dash, capital T. And then now you can see that an actual human readable timestamp is in between the brackets.
Remember that eventually the kernel ring buffer will fill up and the first messages will get discarded. So to see all of the kernel messages since boot, you can look at the var/log/dmesg file, and we can go ahead and run less on that as well. Okay, let's look at the files in the boot directory. Here you will notice that there is an initial RAM disc and a couple of kernels. You'll also notice a GRUB in GRUB2 directory. This system is actually using GRUB2, so the GRUB configuration is stored in that directory.
Traditionally, init control the run levels but if we look at init tab, we'll see a message that reminds us that we're actually using SystemD. Let's check the default target with the command it gives us there. System, CTL, get, dash, default, and you can see that it's at the multi-user target. Let's go ahead and change that to boot into the graphical user interface here. System, set, default, graphical.target. Really all that command did was create a symlink 'cause it shows on the screen there.
Let's run the get default again and see that it does indeed show the graphical target. To change the target, run system, CTL followed by isolate and then the target name so it will go ahead and start the graphical target. Now that we've changed to the graphical target we get a graphical user interface here, so I'll just go ahead and log on. Okay, I hope that helps you understand the boot process going from the BIOS to the boot loader and finally booting up the system. And hopefully that shows you some of the files that are in play in the /boot directory and even how to manipulate run levels or targets as they call them with SystemD.
A world-leading tech and digital skills organization, we help many of the world’s leading companies to build their tech and digital capabilities via our range of world-class training courses, reskilling bootcamps, work-based learning programs, and apprenticeships. We also create bespoke solutions, blending elements to meet specific client needs.