What Is the vmlinuz File in Linux?

The vmlinuz file is the core executable of the Linux operating system, serving as the compressed, bootable Linux kernel. Located typically in the /boot directory, this file is loaded into system memory by the bootloader during startup to initialize hardware, manage system resources, and start the primary user-space processes. This article explains the technical purpose of vmlinuz, its naming convention, how it differs from the raw kernel image, and its step-by-step role in the Linux boot sequence.

Breaking Down the Name: vmlinuz

The name vmlinuz provides insight into its technical design:

vmlinuz vs. vmlinux

During the kernel compilation process, the source code is first compiled into an uncompressed, non-bootable Executable and Linkable Format (ELF) file called vmlinux. While vmlinux contains debugging symbols and the complete, unstripped kernel binary, it is too large and lacks the self-extracting runtime mechanisms required for direct booting on most hardware architectures.

To create vmlinuz, the vmlinux binary is stripped of debugging information, compressed using algorithms such as gzip, bzip2, LZMA, or XZ, and wrapped with a small decompression routine. This produces a smaller, self-extracting executable designed specifically to be handled by bootloaders.

The Function of vmlinuz in the Boot Process

The primary function of vmlinuz is to transition the computer from firmware control to an active operating system environment. It operates through the following sequence:

  1. Loading: During the boot sequence, the system firmware (BIOS or UEFI) executes the bootloader (such as GRUB). The bootloader reads the /boot partition, loads the designated vmlinuz file along with the initial RAM filesystem (initramfs or initrd) into physical RAM.
  2. Self-Decompression: The entry point of vmlinuz executes a small built-in decompression header. This routine decompresses the embedded kernel payload directly into protected system memory.
  3. Kernel Initialization: Control is transferred to the decompressed kernel. The kernel initializes CPU architectures, memory controllers, and essential device drivers bundled within the core image.
  4. Root Filesystem Hand-off: Using temporary drivers and scripts from the initramfs, the kernel mounts the real root filesystem (such as an encrypted drive, LVM volume, or network share).
  5. Spawning PID 1: Once the root filesystem is mounted read-only, the kernel executes the initial user-space process (typically systemd or standard init) with Process ID 1 (PID 1), successfully concluding the kernel's boot phase.

Why the Kernel Is Kept Compressed

Retaining the kernel as a compressed image provides two primary advantages: