Introduction
A raw disk image is an exact copy of a disk, a memory card or a floppy, byte for byte,
with nothing added. It is the simplest disk image there is, and the one written by tools
such as dd. Operating systems for small computers, such as Raspberry Pi
OS, are usually distributed as .img files, often compressed as
.img.xz or .img.zip.
Because there is no header, the file is exactly the size of the disk, unused space
included. The extension .img is also used for other, unrelated formats, so
the contents decide what a particular file is.
Structure
Byte n of the file is byte n of the disk. Whatever the disk held at
its start is what the file starts with. A hard disk or memory card image usually begins
with a master boot record, whose last two
bytes, at offsets 510 and 511, are 55 AA; a disk with a
GUID partition table also has the text
EFI PART at offset 512. A floppy disk image starts with the floppy’s boot
sector, and a 1.44 MB floppy gives a file of exactly 1,474,560 bytes.
0Sector 0 boot sector or master boot record, ending55 AA512 bytes512Sector 1 the GPT headerEFI PART, on GPT disks512 bytes…Partitions and their file systems, in disk orderthe rest of the disk
Not described
Known, not yet covered
- Reference: the structure of the file systems inside a raw disk image (FAT, NTFS, ext4 and others), the bootloader code in the MBR boot area, and GPT attribute bits that a given operating system defines for its own partition types (for example ChromeOS’s).
- Viewer: there is no viewer for raw disk images yet.
Unknown
- Reference: there is no register of MBR partition type bytes; the type table follows util-linux’s list with Brouwer’s descriptions and is not exhaustive (MBR).
Also used for
- GEM Image – GEM desktop bitmaps for PC and Atari ST: a word header and run-length planes.
- Linux boot image – kernel8.img, zImage, uImage and Image: the files a boot loader loads to start Linux.
Links
Software
- dd – the copying tool built into Unix systems, which reads and writes raw images (Linux, macOS, Unix)
- Raspberry Pi Imager – writes images to memory cards (Windows, macOS, Linux)
- balenaEtcher – writes images to USB drives and cards (Windows, macOS, Linux)
- QEMU and qemu-img – run virtual machines from raw images and convert them (Windows, macOS, Linux)
- 7-Zip – free archiver that opens the partitions and files inside many images (Windows)
Developers
- libguestfs – library and tools for reading and changing the files inside disk images (C)