Back to Lab Listing

Lab Objective:

Learn how to manage boot options and understand the boot sequence.

Lab Purpose:

In this lab, you will practice issuing commands to the boot loader and gain a deeper understanding of the Linux boot process, from BIOS/UEFI to completion.

Lab Tool:

Ubuntu 18.04 (or another distro of your choice)

Lab Topology:

A single Linux machine, or virtual machine.

Lab Walkthrough:

Task 1:

Open the Terminal and run:

  • sudo sed -i.bak -e ‘s/GRUB_TIMEOUT=0/GRUB_TIMEOUT=10/’ -e ‘s/GRUB_TIMEOUT_STYLE=hidden/GRUB_TIMEOUT_STYLE=menu/’ -e ‘s/GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”/GRUB_CMDLINE_LINUX_DEFAULT=””/’ /etc/default/grub
  • sudo update-grub

What you’re doing here is modifying the GRUB bootloader so that you can see the boot menu and various logs.

Run dmesg | grep ATA – you are looking for a line indicating your hard disk, beginning with something like ata2.00 or ata3.00. Make a note of this number for later.

Finally, reboot your computer or VM.

Task 2:

Upon boot, you should be greeted with a GRUB menu. Hit ‘c’ to enter the GRUB prompt. Here, you can run various bootloader commands. Use ls to explore your partitions; the format looks a bit different, for example, (hd0,msdos1). There are also commands like lsmod, lspci, and parttool. Do these look familiar? Run help for a full list.

Then, hit ESC to return to the boot menu.

Task 3:

Back at the boot menu, hit ‘e’ to enter a screen where you can modify the boot commands. Depending on your implementation, there may be a lot here, but you are looking for a line beginning with “linux”. This is the line that loads the Linux kernel, and is the most commonly modified line for editing boot options.

At the end of that line, append libata.force=[number]:disable, where [number] is the number you noted above, such as 3.00.

Now, hit Ctrl+X to boot your computer.

Task 4:

After a couple of minutes, you may notice that something has gone wrong! You have disabled your primary hard disk, preventing Linux from booting. It may have looked like it was booting initially, though. That’s because the next step in the boot process is to load the initial RAM disk (initrd) before loading the kernel. The initrd was successful, whereas the kernel step failed, which is why you should have ended up at a(initramfs)prompt.

In short, the Linux boot process goes like this:

  1. BIOS/UEFI enumerates hardware and loads code from the configured boot device (not Linux-specific).
  2. GRUB bootloader loads, parses boot commands, and options.
  3. Initrd is loaded, bootstraps various filesystems and modules, and then loads the kernel.
  4. The init process is launched, which in turn executes all startup processes as configured within Linux.

Type “reboot” to reboot your computer/VM and return it to normal.

If you’d like to undo the GRUB changes made in step 1, just run:

  • sudo mv /etc/default/grub{.bak,}
  • sudo update-grub

Notes:

The reason an initial RAM disk is used is that Linux is a generic operating system meant to run on a wide variety of hardware and disk configurations. Enabling checks for all these configurations in the kernel directly would make the kernel much larger than necessary. Thus, a temporary filesystem is used to handle all special-case cases, and then load the correct modules along with the kernel.

Newsletter Subscribe

Stay Informed, Stay Inspired: Subscribe for Cutting-Edge IT-Certification Insights

101 Labs Newsletter