Linux - vmlinux vs vmlinuz
vmlinux vs vmlinuz
The difference between vmlinux and vmlinuz comes down to whether the kernel is compressed or not.
In the world of virtualization (like Kata Containers or Firecracker), knowing which one to use is important for boot speed and memory management.
vmlinux (The "Raw" Kernel)
The vmlinux is a non-compressed, non-bootable (directly), statically linked executable file in the ELF format.
- How it's made: It is the immediate output of the Linux kernel compilation process.
- State: Uncompressed. Because it isn't compressed, the file size is quite large (often 100MB+ depending on the configuration).
- Usage in Debugging: Because it is a standard ELF file, it contains all the symbol information needed for debugging. If you want to use a tool like
gdbto inspect the kernel, you use thevmlinuxfile. - Usage in Micro-VMs: Some modern hypervisors, like Firecracker, often prefer an uncompressed
vmlinux. Since Firecracker handles the loading of the kernel directly into memory, it can skip the decompression step, making the boot time even faster (milliseconds).
vmlinuz (The "Bootable" Kernel)
The vmlinuz is the compressed version of the Linux kernel. The "z" at the end stands for "zipped" (historically using zlib, but now often gzip, xz, or zstd).
- How it's made: The build process takes the
vmlinuxfile, strips out debugging information, compresses it, and wraps it in a small piece of "bootloader" code. - State: Compressed. It is much smaller than
vmlinux(usually 5MB to 10MB). - Self-Extracting: When the computer starts, the small piece of code at the beginning of the
vmlinuzfile runs first. It decompresses the kernel into RAM and then "jumps" to the start of the kernel code to begin the OS boot. - Location: This is the file you will find in your
/bootdirectory on a standard Linux machine (e.g.,/boot/vmlinuz-5.15.0-generic).
Key Comparison
| Feature | vmlinux | vmlinuz |
|---|---|---|
| Full Name | Virtual Memory Linux | Virtual Memory Linux Zipped |
| Format | Standard ELF Executable | bzImage (usually) |
| Compression | None (Uncompressed) | Compressed (zstd, gzip, etc.) |
| Size | Large (100MB+) | Small (5MB - 10MB) |
| Debuggable | Yes (contains symbols) | No (symbols are stripped) |
| Self-Extracting | No | Yes |
| Boot Speed | Faster (no decompression needed) | Slightly slower (must decompress) |
| Common Use | Debugging / Firecracker / KVM | Desktop Linux / Servers / Grub |
What is "vm" in "vmlinux"?
In the names vmlinux and vmlinuz, the "vm" stands for Virtual Memory.
It is a common point of confusion today, but it does not stand for "Virtual Machine."
The History of the "vm"
To understand why it's there, we have to look back to the early 1990s:
- Before Virtual Memory: Early operating systems (and very early versions of Linux) ran on CPUs that didn't have sophisticated memory management. Programs interacted directly with physical RAM addresses.
- The 80386 Revolution: When Linux was being developed, the Intel 80386 chip became popular. It featured an MMU (Memory Management Unit) that supported Paging and Virtual Memory.
- The "vm" Prefix: This allowed the kernel to map "virtual" addresses to "physical" RAM. This was a massive architectural leap. To distinguish the new kernel that supported these features from older, simpler versions, the prefix "vm" was added.
What is Virtual Memory?
In this context, Virtual Memory is the technology that allows:
- Isolation: Process A cannot see the memory of Process B. Every process thinks it has the entire memory range to itself (starting at address
0). - Swapping: The kernel can pretend you have more RAM than you actually do by "swapping" unused chunks of memory to the hard drive.
- Protection: It prevents a regular application from accidentally (or intentionally) writing data into the kernel's private memory space.
The Common Misconception: "Virtual Machine"
Because we frequently use vmlinux files to boot Virtual Machines (like in Kata Containers or Firecracker), many people assume the "vm" stands for Virtual Machine.
However:
- vmlinux was named in the early 90s.
- Linux-based Virtual Machines (via KVM) didn't become a standard part of Linux until 2007.
The irony: You use a Virtual Memory Linux (vmlinux) kernel to boot a Virtual Machine (VM).