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
Also used for
- GEM Image .img
Links
Software
- dd, the copying tool built into Linux, macOS and other Unix systems
- Raspberry Pi Imager, which writes images to memory cards (Windows, macOS, Linux)
- balenaEtcher, which writes images to USB drives and cards (Windows, macOS, Linux)
- QEMU and qemu-img, which run virtual machines from raw images and convert them (Windows, macOS, Linux)
- 7-Zip, which opens the partitions and files inside many images (Windows)
Developers
- libguestfs, C library and tools for reading and changing the files inside disk images