Operating Systems Concepts & Design
The process of loading the root file system (/) is a coordinated handoff between the hardware, the bootloader, and a temporary mini-operating system called the initramfs.
Because the kernel cannot read the hard drive until it has the proper drivers—and the drivers are usually stored on the hard drive—Linux uses a “bootstrap” method to bridge the gap.
Once the bootloader (usually GRUB) loads the Linux kernel into memory, it also loads a compressed archive called the initramfs (Initial RAM File System).
Inside the initramfs, a script (often named init) runs. Its job is to find the physical partition that contains the actual / file system. It uses parameters passed from the bootloader, such as:
root=UUID=550e8400-e29b-...root=/dev/nvme0n1p2The kernel uses its built-in drivers or the modules loaded from the initramfs to “see” the hardware devices and identify the correct UUID.
Once the device is identified (e.g., /dev/sda1), the kernel performs a mount operation:
fsck) at this stage./) to begin mapping the file tree.This is the most critical step. The system is currently running off the RAM-based initramfs, but it needs to transition to the disk-based filesystem.
switch_root (or pivot_root)./.Now that the real / is mounted, the kernel looks for the first user-space program to run, typically located at /sbin/init (which is usually a symbolic link to systemd).
Systemd then takes over, reading /etc/fstab to mount all other filesystems (like /home or /var) and starting the background services (daemons) that make the system functional.
| Component | Responsibility |
|---|---|
| Bootloader | Loads Kernel and Initramfs into RAM. |
| Initramfs | Provides the drivers to “talk” to the hard drive. |
| Kernel | Reads the Superblock and mounts the physical partition. |
| switch_root | Swaps the temporary RAM-disk for the real disk. |
| systemd | Starts the OS services from the real disk. |
fstab used?While the kernel and the bootloader handle the “magic” of mounting the root (/) filesystem, /etc/fstab (the Filesystem Table) comes into play immediately afterward during the User Space initialization.
Think of it as a two-stage process: the kernel gets the “foundation” (the root) ready, and then systemd (or your init system) uses fstab to build the rest of the “house.”
The system cannot read /etc/fstab until the root filesystem is already mounted.
/ (the root) using the root= parameter from the bootloader.switch_root to the real disk./, the init process (systemd) finally has access to the file path /etc/fstab.Modern Linux systems use systemd, which doesn’t just “read” the fstab file; it converts it.
systemd-fstab-generator runs. It parses /etc/fstab and dynamically creates systemd mount units (e.g., home.mount or data.mount) in a temporary directory (/run/systemd/generator/)./var/log, it knows it must mount /var before it can mount /var/log.Once the generators have finished, the system starts the local-fs.target. This is the point in the boot sequence where:
pass column (the 6th field) in fstab to see if it needs to run fsck on those partitions.noauto option.remote-fs.target and mounts things like NFS or SMB shares defined in fstab.Because fstab is processed so early, errors can be critical:
auto) fails to mount, the system may drop into Emergency Mode (a bare-bones shell) because it considers the system state “incomplete.”nofail Option: If you have an external drive or a non-essential partition, adding nofail to the options column in fstab tells the system to keep booting even if that specific device is missing.| Feature | Root (/) Mounting | fstab Mounting |
|---|---|---|
| Triggered By | Kernel / Initramfs | systemd (Init System) |
| Source of Info | Bootloader (GRUB) cmdline | /etc/fstab file |
| Target | Only the Root partition | /home, /var, /tmp, swap, etc. |
| Error Result | Kernel Panic (VFS: Unable to mount) | Emergency Mode / Maintenance Shell |
/etc/fstabCreating an entry in /etc/fstab requires a specific six-field syntax. Each field tells the system exactly how to handle the device during the boot process.
Before you start, you need the UUID (Universally Unique Identifier) of the partition. While you can use device names like /dev/sdb1, these can change if you plug in a new drive. UUIDs are permanent.
Run the following command to find the UUID and the filesystem type (TYPE) of your target partition:
lsblk -f
Take note of the UUID string (e.g., 550e8400-e29b-41d4-a716-446655440000) and the FSTYPE (e.g., ext4).
An entry consists of six fields separated by tabs or spaces:
| Field | Purpose | Example |
|---|---|---|
| 1. Device | The UUID or device path | UUID=1234-abcd-... |
| 2. Mount Point | Where the folder lives in / |
/mnt/backup |
| 3. Filesystem | The format of the partition | ext4 |
| 4. Options | Mount behavior (read/write, etc.) | defaults |
| 5. Dump | Used by backup tools (rarely used) | 0 |
| 6. Pass | Order for fsck disk check |
2 |
While defaults works for most cases, you can customize behavior:
defaults: Includes rw (read-write), suid, dev, exec, auto, nouser, and async.nofail: If the drive is missing (like a USB drive), the system will continue booting instead of hanging.ro: Mounts the filesystem as Read-Only.noatime: Stops the system from writing “last accessed” timestamps to files (improves performance on SSDs).sudo mkdir -p /mnt/my_datasudo nano /etc/fstab
4. **Save and Exit:** (In Nano, press `Ctrl+O`, `Enter`, then `Ctrl+X`).
---
### Step 5: Test Without Rebooting (Critical)
**Never reboot immediately after editing fstab.** If there is a typo, your system might fail to boot.
Run this command to test the configuration:
```bash
sudo mount -a
/etc/fstab for typos or incorrect UUIDs before you restart.initramfs and the Boot Loader (GRUB)To view these components, you have to peel back the layers of the boot process. One lives as a compressed archive on your /boot partition, and the other is a configuration file that dictates what you see on your monitor before Linux even starts.
The initramfs is usually a compressed CPIO archive located in /boot. You cannot simply cat it; you need to decompress it or use a specialized tool to peek inside.
lsinitramfsMost Debian/Ubuntu-based systems include a utility that lists the contents without manual decompression.
bash
lsinitramfs /boot/initrd.img-$(uname -r) | less
```
scripts/ directory (where the boot logic lives) and lib/modules/ (where the drivers for your storage and file systems are stored).If you want to actually read the scripts inside, you can extract it to a temporary folder:
mkdir /tmp/initrd && cd /tmp/initrdunmkinitramfs /boot/initrd.img-$(uname -r) .cd into the folders and use cat to read the init script that handles the “switch root” process.The “menu” you see at boot is generated by GRUB. While the active configuration is a complex script, the human-readable source is much easier to digest.
On modern Linux systems, you should look at /etc/default/grub. This file controls the menu timeout, the default OS, and kernel parameters (like root=UUID...).
cat /etc/default/grubGRUB_TIMEOUT=5 (how long the menu stays up) and GRUB_CMDLINE_LINUX_DEFAULT (the options passed to the kernel).The actual file GRUB reads at boot is /boot/grub/grub.cfg.
update-grub command.less /boot/grub/grub.cfgmenuentry. This block defines each line you see on your boot screen, including the linux and initrd lines that point to the files we discussed earlier.If you decide to modify your fstab or your GRUB configuration, you can verify your work before a reboot “breaks” the system:
sudo mount -a. If it returns no errors, your fstab syntax is correct and the partitions are mountable./etc/default/grub, you must run sudo update-grub to push those changes into the actual boot script.| Component | Primary Location | Command to View |
|---|---|---|
| Initramfs | /boot/initrd.img-... |
lsinitramfs |
| GRUB Settings | /etc/default/grub |
cat |
| GRUB Menu Logic | /boot/grub/grub.cfg |
less |