Introduction
A boot loader starts Linux by loading one file into memory and jumping to it. That file is a boot image, and
what it looks like depends on the processor and on the loader. None of these files has an extension that tells you what it is:
the ones on a Raspberry Pi boot partition are kernel8.img and kernel7.img, and elsewhere you find
Image, zImage and uImage. What identifies each is a magic number at a fixed place
in its header, so the explorer looks there, and a file with no extension, or with .img, is recognised by it.
The formats
| Format | Magic | What it is |
|---|---|---|
| ARM64 Image | ARM\x64 at offset 56 | The uncompressed 64-bit ARM kernel with a 64-byte header. kernel8.img on a 64-bit Raspberry Pi, after the firmware has unpacked it, is one. |
| ARM zImage | 0x016F2818 at offset 0x24 | A self-extracting 32-bit ARM kernel: a stub followed by the compressed kernel. kernel7.img and kernel.img on a Raspberry Pi. |
| U-Boot uImage | 0x27051956 at offset 0 | A 64-byte header made by mkimage in front of any file: a kernel, a RAM disk, a devicetree. |
| RISC-V Image | RSC\x05 at offset 56 | The 64-byte header of the RISC-V Linux kernel, laid out like the ARM64 one. |
| LoongArch Image | MZ at offset 0, 0x818223CD at offset 56 and a LoongArch PE header | The uncompressed LoongArch Linux kernel: a 64-byte header that is also a DOS header, then the PE header of an EFI application. |
| FIT image | 0xD00DFEED at offset 0, with /images and /configurations nodes | U-Boot’s newer image format: a devicetree blob that holds the kernel, devicetree and RAM disk as properties, with hashes. .itb. |
| EFI zboot image | MZ at offset 0 and zimg at offset 4 | A PE/COFF EFI application whose DOS header carries a payload offset, size and compression type; the kernel inside is compressed (gzip in the Alpine arm64 vmlinuz-virt). vmlinuz.efi, or vmlinuz of an arm64, RISC-V or LoongArch distribution. |
| x86 kernel image | HdrS at offset 0x202 (and 0xAA55 at 0x1FE) | The x86 bzImage or vmlinuz: a boot sector, real-mode setup code and a compressed protected-mode kernel, described by the boot protocol header; modern ones are also EFI applications. |
| Android boot image | ANDROID! at offset 0 | boot.img, init_boot.img, recovery.img: a header (versions 0 to 4) in front of a kernel, a ramdisk and, in older versions, a second stage and device trees. |
| Android vendor boot image | VNDRBOOT at offset 0 | vendor_boot.img (header versions 3 and 4): the vendor ramdisks, the DTB and, in version 4, a ramdisk table and the bootconfig. |
| Android vbmeta and AVB footer | AVB0 at offset 0 (vbmeta); AVBf in the last 64 bytes (footer) | Android Verified Boot: the signed metadata that says which hashes and keys the partitions must match. |
A .gz kernel (Image.gz) is a gzip file: the explorer unpacks it and reads the result as one of the four. An EFI zboot image starts with MZ, so it is told from an ordinary EFI program by the letters zimg and the Linux marker 0x818223CD at offset 0x38: the .efi row of the explorer asks that test first.
In the explorer
Each viewer shows the header field by field with its checks, and, for the processors it has a disassembler for, the first bytes of the code: the ARM64 Image with the AArch64 decoder, the zImage with the ARM decoder (ARMv7-A by default, with a choice of ARM or Thumb-2 and of architecture), the RISC-V Image with the RISC-V decoder (RV64GC by default, with a choice). The rest of a kernel is not explained: it is code and data mixed, and the viewers do not name its functions. A uImage opens its data as a file of its own, and checks both CRC-32 values.
Also used for
- GEM Image – GEM desktop bitmaps for PC and Atari ST: a word header and run-length planes.
- Raw disk image – A disk or memory card copied byte for byte, with no header.
Not described
Known, not yet covered
- Reference and viewer: the Raspberry Pi boot partition files other than the kernels are not covered here.
- Viewer: a boot image or kernel with no extension is found by name alone only where the explorer's by-magic finder knows it (the arm64, RISC-V, zImage, uImage and zboot kinds); the Android images and the x86 kernel image are found by their magic when the name ends in
.imgor.efi. - Viewer: the compressed kernel inside a zImage is not unpacked: the format does not say where it starts.
Unknown
- Reference: the Raspberry Pi firmware files
bootcode.bin,start4.elfandfixup4.dathave no public format description that we have found;start4.elfis an ELF file and opens as one.
Links
Software
Reference
- Booting AArch64 Linux – the ARM64 Image header
- Booting ARM Linux – how a boot loader starts a zImage
- Boot image header in RISC-V Linux
- Booting Linux/LoongArch – the LoongArch Image header
- U-Boot include/image.h – the uImage header and its code tables