Installing My First Linux Operating System - Part 01

·

5 min read

To gain a deeper understanding of Linux and the boot process, I was advised by a coworker to go through the installation process of GentooOS. I do have an old laptop that I can dust off and use, so here I am giving this a try and documenting my learnings throughout. To prepare, all I have done so far is transfer all files out of the laptop.

CPU Architecture - Selecting the Right Handbook

Apprently the official Gentoo Handbook (wiki.gentoo.org/wiki/Handbook) is like the Holy Bible to follow. Right away, I need to figure out the instruction set architecture of my laptop. This is important because different CPUs have different instruction sets that determine how the processor interprets and executes instructions.

The specific CPU inside my laptop is the Intel i5-7200U, what made me initially think that the architecture is x86. However, the description says that x86 is a 32-bit architecture, while my CPU is 64-bit. The actual architecture is AMD64, which is 64-bit and compatible with x86. The confusion of its name comes from the fact that AMD was the company that released 64-bit x86 CPUs, and is synonymous with x86-64.

Linux Image

Continuing through the handbook, the next step is to create a bootable image. To explain - an image is a snapshot of a pre-configured installation of an operating system that includes all the necessary files (e.g. kernel, drivers, configs..). This is not the case for Gentoo's recommended image, which only includes a minimal image since it's designed to be customizable. The general steps will be to get the image onto an installation medium, booting my laptop into this installation medium, and use it to install the necessary drivers and perform configurations.

The first Gentoo Linux installation medium that the handbook lists is the "Minimal Installation CD", which is a bootable ISO file that contains the minimum necessary files to install Gentoo Linux. This confused me quite a bit until I figured out that while the name suggests that a physical compact disk is required, the image can also be used to create a bootable USB drive. After downloading the minimal installation cd, the handbook recommends to verify the downloaded files. I am going to naively skip this step due to time considerations (laziness).

Burning the Image

After downloading the minimal installaton iso file, I need to burn it to a USB so that my laptop can boot from it. For reference, an iso file is an archive file (file composed of one or more files along with metadata) that contains everything that would be written to an optical disk, sector by sector. This goes hand-in-hand in answering my next question: why do we need to burn the image instead of just copying it over? This is because we want the USB to be a bootable drive. When a computer starts up, it checks all connected devices, and detects if it's bootable by looking for a boot sector or boot loader on the drive. When we copy files to a USB drive, file system structure information gets lost (e.g. disk partitions). Thus, we need to burn the iso to the usb to preserve the file system structure so that the drive can boot properly.

To burn the image onto the USB, I used Rufus (rufus.ie/en). I kept all options default, except for the partition scheme, which I changed from MBR to GPT.

Block Devices and Partitioning Schemes

rufus img

I don't exactly know what I'm doing but here's what I learned, hopefully structured in a way that flows logically.

  1. Devices are interfaces that allow programs and drivers to interact with the physical hardware. There are two types of devices that allow communication between the computer and physical hardware - character devices and block devices.

  2. Drivers communicate with character devices by sending and receiving single characters (bytes), though they can be buffered. Examples of character devices include sound cards, mice, and keyboards.

  3. Drivers communicate with block devices by sending/receiving blocks of data and often storage devices. Examples include USBs, hard disks, and SSDs.

  4. Block devices are often partitioned into separate, smaller block devices that can be formatted independently. This allows use cases such as having different operating systems on different partitions, or using different partitions for different use cases. There are two common types of partitioning strategies - MBR (Master Boot Record) and GPT (GUID Partitioning Table).

  5. Whether MBR or GPT is used depends on the motherboard firmware. MBR is used in older BIOS-based systems, while GPT is used on modern UEFI-based systems. GPT is also backwards compatible with BIOS.

  6. BIOS (Basic Input/Output System) is responsible for initializing hardware and tests that hardware is good to go (via POST: power-on self test), and it's main job is to load up the bootloader, which is stored in the MBR, the first 512 bytes of the boot disk. BIOS also limits disk size to 2TB.

  7. UEFI (Unified Extensible Firmware Interface) is more advanced and modular than BIOS, such as supporting larger disks and having a more advanced bootloader. In UEFI, startup info is stored in the EFI system partition. The bootloader is stored as an .efi file, and the EFI partition can also contain other files such as drivers and configuration files. UEFI uses the GPT partitioning scheme, which supports up to 128 partitions on a single disk and >2TB disks.

Based on the above information, I chose GPT as the partitioning scheme, since my laptop also runs Windows 10, which is UEFI based.