Once the bootloader has finished, the Linux kernel is in charge. It sets up the processor, memory management and the drivers it was built with.
The chicken and egg problem
The kernel must mount the root filesystem, but the driver for that disk may be a loadable module, and modules are files stored on the root filesystem. Encrypted disks, LVM and software RAID add more steps that must happen first.
The initramfs solves this. It is a compressed archive that the bootloader loads into memory next to the kernel. The kernel unpacks it into a temporary root filesystem and runs the /init program inside it. That program loads the needed modules, finds the real root device and switches over to it.
Mounting the root filesystem
The root filesystem is often mounted read-only first, because of the ro parameter. This lets it be checked safely. Later in the boot it is remounted read-write.
If the kernel cannot find or mount a root filesystem, it may stop with a panic such as VFS: Unable to mount root fs. With an initramfs, you may instead land in a small emergency shell. Wrong root= values and missing storage drivers are typical causes.
Finally, control moves to user space when the init program on the real root filesystem is started.
Reading kernel messages
The kernel writes messages into a ring buffer. dmesg prints it. Many distributions require sudo.
$ sudo dmesg | head -3
[ 0.000000] Linux version 6.8.0-45-generic (...)
[ 0.000000] Command line: root=/dev/sda2 ro quiet
[ 0.000000] BIOS-provided physical RAM map:The number in brackets is seconds since the kernel started. Because the buffer has a fixed size, old messages are eventually overwritten.
Kernel files and versions
Check which kernel is running:
$ uname -r
6.8.0-45-genericThe installed images and initramfs files are in /boot:
$ ls /boot
config-6.8.0-45-generic grub initrd.img-6.8.0-45-generic vmlinuz-6.8.0-45-genericNames vary by distribution. To look inside an initramfs, Debian-based systems offer lsinitramfs, while systems using dracut offer lsinitrd. Distributions rebuild the initramfs when a kernel is installed, using update-initramfs on Debian and Ubuntu or dracut on Fedora and RHEL.
Try it
Run uname -r, then confirm that /boot has a kernel and an initramfs with that version in the name. Next, run sudo dmesg | grep -i 'command line' and compare the result with /proc/cmdline. If nothing appears, the early messages have probably been overwritten.
Check your understanding
Boot Process: Kernel
All 4 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.