The Mysteries of vmlinuz: What It Is and Why It’s Named That Way
What is the vmlinuz file?
If you’ve ever looked into your Linux system’s /boot directory, you’ve surely come across a file with the mysterious name vmlinuz (or vmlinuz-6.5.0-generic, etc.). This is one of the most important files in the entire system – it’s the compressed, bootable image of the Linux kernel.
In short, this is the file that is loaded into memory by the bootloader (like GRUB) when the computer starts. Once loaded, a small piece of code inside vmlinuz decompresses the rest of the kernel into RAM and then transfers control to it, beginning the actual startup process of the operating system.
Fun Fact #1: What does the name vmlinuz mean?
The name vmlinuz is not accidental. It’s an acronym that can be broken down into parts, each with historical significance:
vm: Stands for “Virtual Memory”. In the early days of Linux, kernels that supported virtual memory (which is standard today) had this prefix to distinguish them from older versions that did not.linu: This is simply short for “Linux”.z: This indicates that the kernel image is compressed, most often using the zlib algorithm. It is this compression that makes the file much smaller than its raw counterpart,vmlinux.
Fun Fact #2: vmlinux vs vmlinuz
You might also often come across a file named vmlinux (without the “z” at the end). What’s the difference?
vmlinux: This is the raw, uncompressed, non-bootable kernel image. It contains all the debugging symbols and is in ELF format. It is huge compared tovmlinuzand is mainly used for debugging and analyzing the kernel with tools likegdborcrash.vmlinuz: This is the compressed and “stripped” version ofvmlinux, prepared specifically for booting the system.
The process of creating vmlinuz from vmlinux involves removing unnecessary information, compressing it, and adding a small startup code responsible for decompression.
Fun Fact #3: What about bzImage?
When compiling the kernel, the command make bzImage is often used. Many people think that bz stands for bzip2 compression. Nothing could be further from the truth!
Historically, the first compressed kernel image was called zImage (from “zlib Image”). However, it had a limitation – the entire compressed kernel had to fit into the first 640 KB of memory. As the kernel grew, this became a problem.
So, the bzImage format was introduced, where bz stands for “big zImage”, not bzip2. bzImage also uses zlib compression (or newer ones like lzo, xz), but thanks to a different memory organization, it allows for loading much larger kernel images. Today, bzImage is the de facto standard, and the file it generates is our vmlinuz.
Summary
The vmlinuz file is the heart of our system during startup. Its name and format are the result of decades of Linux kernel evolution – from simple beginnings, through the addition of virtual memory, to the need to load ever larger and more complex kernels. It’s a small file with a big history!