Vmlinux

Last updated
Linux kernel boot and decompression process Linux-kernel-vmlinux.png
Linux kernel boot and decompression process

vmlinux is a statically linked executable file that contains the Linux kernel in one of the object file formats supported by Linux, which includes Executable and Linkable Format (ELF) and Common Object File Format (COFF). The vmlinux file might be required for kernel debugging, symbol table generation or other operations, but must be made bootable before being used as an operating system kernel by adding a multiboot header, bootsector and setup routines.

Contents

Etymology

Traditionally, UNIX platforms called the kernel image /unix. With the development of virtual memory, kernels that supported this feature were given the vm- prefix to differentiate them. The name vmlinux is a mutation of vmunix, while in vmlinuz the letter z at the end denotes that it is compressed (for example gzipped). [1]

Location

Traditionally, the kernel was located in the root directory of the filesystem hierarchy; however, as the bootloader must use BIOS drivers to access the hard disk, limitations on some i386 systems meant only the first 1024 cylinders of the hard disk were addressable.

To overcome this, Linux distributors encouraged users to create a partition at the beginning of their drives specifically for storing bootloader and kernel-related files. GRUB, LILO and SYSLINUX are common bootloaders.

By convention, this partition is mounted on the filesystem hierarchy as /boot. This was later standardised by the Filesystem Hierarchy Standard (FHS), which now requires the Linux kernel image to be located in either / or /boot, although there is no technical restriction enforcing this. [2]

Compression

Traditionally, when creating a bootable kernel image, the kernel is also compressed using gzip, or, since Linux 2.6.30, [3] using LZMA or bzip2, which requires a very small decompression stub to be included in the resulting image. The stub decompresses the kernel code, on some systems printing dots to the console to indicate progress, and then continues the boot process. Support for LZO, [4] xz, [5] LZ4 [6] and zstd [7] compression was added later.

The decompression routine is a negligible factor in boot time, and prior to the development of the bzImage, the size constraints of some architectures, notably i386, were extremely limiting, making compression a necessity.

On the SPARC architecture, the vmlinux file is compressed using simple gzip, because the SILO boot loader transparently decompresses gzipped images.

The filename of the bootable image is not important, but many popular distributions use vmlinuz.

bzImage

Anatomy of a bzImage Anatomy-of-bzimage.png
Anatomy of a bzImage

As the Linux kernel matured, the size of the kernels generated by users grew beyond the limits imposed by some architectures, where the space available to store the compressed kernel code is limited. The bzImage (big zImage) format was developed to overcome this limitation by splitting the kernel over non-contiguous memory regions.[ citation needed ]

The bzImage was compressed using gzip until Linux 2.6.30, [3] which introduced more algorithms. Although the bz prefix may suggest that bzip2 compression is used, this is not the case.[ citation needed ] (The bzip2 package is often distributed with tools prefixed with bz, such as bzless, bzcat, etc.)

The bzImage file is in a specific format. It contains concatenated bootsect.o + setup.o + misc.o + piggy.o. [8] piggy.o contains the gzipped vmlinux file in its data section. The script extract-vmlinux found under scripts/ in the kernel sources decompresses a kernel image. Some distributions (e.g. Red Hat and clones) may come with a kernel-debuginfo RPM that contains the vmlinux file for the matching kernel RPM, and it typically gets installed under /usr/lib/debug/lib/modules/`uname -r`/vmlinux or /usr/lib/debug/lib64/modules/`uname -r`/vmlinux.

See also

Notes and references

  1. "vmlinuz Definition". www.linfo.org. Bellevue Linux. March 29, 2005. Retrieved 2015-06-21.
  2. "Section 3.5.2 — /boot : Static files of the boot loader". FHS 2.3. 2004-01-29. Retrieved 2014-03-11. The operating system kernel must be located in either / or /boot.
  3. 1 2 Linux 2.6.30, released the 9th of June 2009, added support to compress the kernel image with the LZMA and bzip2 algorithms
  4. Linux 2.6.33, released on February 24, 2010, added support to compress the kernel image with LZO
  5. Linux 2.6.38, released on March 14, 2011, added support to compress the kernel image with xz
  6. Linux 3.11, released on September 2, 2013, added support to compress the kernel image with LZ4
  7. Linux 5.9, released on October 11, 2020, added support to compress the kernel image, initrd and initramfs with zstd
  8. Yann Droneaud (1999-09-28). "Re: bzImage decompression". LKML (Mailing list). The zImage contain bootsect.o + setup.o + misc.o + piggy.o

Further reading

Related Research Articles

gzip GNU file compression/decompression tool

gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and intended for use by GNU. Version 0.1 was first publicly released on 31 October 1992, and version 1.0 followed in February 1993.

bzip2 File compression software

bzip2 is a free and open-source file compression program that uses the Burrows–Wheeler algorithm. It only compresses single files and is not a file archiver. It relies on separate external utilities for tasks such as handling multiple files, encryption, and archive-splitting.

In computing, tar is a computer software utility for collecting many files into one archive file, often referred to as a tarball, for distribution or backup purposes. The name is derived from "tape archive", as it was originally developed to write data to sequential I/O devices with no file system of their own, such as devices that use magnetic tape. The archive data sets created by tar contain various file system parameters, such as name, timestamps, ownership, file-access permissions, and directory organization. POSIX abandoned tar in favor of pax, yet tar sees continued widespread use.

<span class="mw-page-title-main">7-Zip</span> Open-source file archiver

7-Zip is a free and open-source file archiver, a utility used to place groups of files within compressed containers known as "archives". It is developed by Igor Pavlov and was first released in 1999. 7-Zip has its own archive format called 7z, but can read and write several others.

<span class="mw-page-title-main">StuffIt Expander</span> File decompressor software utility

StuffIt Expander is a proprietary, freeware, closed source, decompression software utility developed by Allume Systems. It runs on the classic Mac OS, macOS, and Microsoft Windows. Prior to 2011, a Linux version had also been available for download.

rzip is a huge-scale data compression computer program designed around initial LZ77-style string matching on a 900 MB dictionary window, followed by bzip2-based Burrows–Wheeler transform and entropy coding (Huffman) on 900 kB output chunks.

lzop is a free software file compression tool which implements the LZO algorithm and is licensed under the GPL.

Lempel–Ziv–Oberhumer (LZO) is a lossless data compression algorithm that is focused on decompression speed.

<span class="mw-page-title-main">UPX</span>

UPX is a free and open source executable packer supporting a number of file formats from different operating systems.

dar is a computer program, a command-line archiving tool intended as a replacement for tar in Unix-like operating systems.

In Linux systems, initrd is a scheme for loading a temporary root file system into memory, to be used as part of the Linux startup process. initrd and initramfs refer to two different methods of achieving this. Both are commonly used to make preparations before the real root file system can be mounted.

The SPARC Improved bootLOader (SILO) is the bootloader used by the SPARC port of the Linux operating system; it can also be used for Solaris as a replacement for the standard Solaris boot loader.

Squashfs is a compressed read-only file system for Linux. Squashfs compresses files, inodes and directories, and supports block sizes from 4 KiB up to 1 MiB for greater compression. Several compression algorithms are supported. Squashfs is also the name of free software, licensed under the GPL, for accessing Squashfs filesystems.

The multi-stage booting process of Linux is in many ways similar to the BSD and other Unix-style boot processes, from which it derives.

<span class="mw-page-title-main">Xarchiver</span>

Xarchiver is a front-end to various command line archiving tools for Linux and BSD operating systems, designed to be independent of the desktop environment. It is the default archiving application of Xfce and LXDE. Deepin's archive manager is based on Xarchiver.

XZ Utils is a set of free software command-line lossless data compressors, including the programs lzma and xz, for Unix-like operating systems and, from version 5.0 onwards, Microsoft Windows. For compression/decompression the Lempel–Ziv–Markov chain algorithm (LZMA) is used. XZ Utils started as a Unix port of Igor Pavlov's LZMA-SDK that has been adapted to fit seamlessly into Unix environments and their usual structure and behavior.

lzip Data compression utility

lzip is a free, command-line tool for the compression of data; it employs the Lempel–Ziv–Markov chain algorithm (LZMA) with a user interface that is familiar to users of usual Unix compression tools, such as gzip and bzip2.

LZ4 is a lossless data compression algorithm that is focused on compression and decompression speed. It belongs to the LZ77 family of byte-oriented compression schemes.

Zstandard, commonly known by the name of its reference implementation zstd, is a lossless data compression algorithm developed by Yann Collet at Facebook. Zstd is the reference implementation in C. Version 1 of this implementation was released as open-source software on 31 August 2016.

EROFS is a lightweight read-only file system initially developed by Huawei for the Linux kernel and now maintained by an open-source community from all over the world.