> For the complete documentation index, see [llms.txt](https://book.loliteam.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.loliteam.net/101-labs-for-linux/hardware-and-system-configuration/lab-1-boot-sequence.md).

# LAB 1 - 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:

{% code overflow="wrap" lineNumbers="true" %}

```shell
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
```

{% endcode %}

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, causing Linux to be unable to boot. It may have looked like it was booting initially, though. That’s because the next step of the boot process is to load the initial RAM disk (initrd), prior to 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 normalcy.

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

{% code overflow="wrap" lineNumbers="true" %}

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

{% endcode %}

### Notes:

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.loliteam.net/101-labs-for-linux/hardware-and-system-configuration/lab-1-boot-sequence.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
