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:
- vm: Stands for "Virtual Memory." Linux kernels gained this prefix when support for virtual memory architecture was implemented, allowing systems to utilize hard drive swap space to supplement physical RAM.
- linux: Refers directly to the Linux operating system kernel.
- z: Indicates compression. In Unix traditions, compressed files historically carried a "z" extension. The presence of the "z" distinguishes a compressed kernel image from an uncompressed one.
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:
- Loading: During the boot sequence, the system
firmware (BIOS or UEFI) executes the bootloader (such as GRUB). The
bootloader reads the
/bootpartition, loads the designatedvmlinuzfile along with the initial RAM filesystem (initramfsorinitrd) into physical RAM. - Self-Decompression: The entry point of
vmlinuzexecutes a small built-in decompression header. This routine decompresses the embedded kernel payload directly into protected system memory. - 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.
- 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). - Spawning PID 1: Once the root filesystem is mounted
read-only, the kernel executes the initial user-space process (typically
systemdor standardinit) 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:
- Faster Boot Times: Reading a smaller file from a storage drive (especially legacy hard disk drives or network boot environments) takes significantly less time than reading an uncompressed binary. The modern CPU can decompress the kernel in memory far faster than the storage controller could read the uncompressed equivalent from disk.
- Storage Efficiency: Maintaining multiple versions
of
vmlinuzinside/bootallows administrators to roll back to older kernels if an update fails, all while consuming minimal disk space on dedicated boot partitions.