SD Card Image: What It Is & How to Create One
In this article
To create an image of an SD card means to make a single file that contains an exact, byte-for-byte copy of the card's entire contents — including its partition table, file system, and all data. This is useful for backing up a card, cloning it to another card, or creating a bootable image for a Raspberry Pi or other single-board computer.
What Is an SD Card Image?
An SD card image is a file (often with a .img or .iso extension) that represents the complete raw contents of the card. Unlike copying files from the card to a folder, an image preserves the card's structure exactly. This includes the master boot record, partition table, and every sector of data, even the empty ones. Because of this, an image can be written back to another SD card to produce a card that is functionally identical to the original.
Images are commonly used for:
- Creating a backup of a working system (e.g., a Raspberry Pi OS installation)
- Duplicating a card to deploy the same setup to multiple devices
- Archiving a card before modifying it, so you can restore it later
- Downloading pre-made operating system images for devices like the Raspberry Pi
How to Create an SD Card Image
The process involves reading the raw data from the SD card and saving it to a file on your computer. The exact steps vary by operating system, but the fundamental approach is the same.
- Insert the SD card into your computer's card reader.
- Identify the correct device name for the card (e.g., /dev/sdb on Linux, disk2 on macOS, or a drive letter on Windows). Be extremely careful — using the wrong device can overwrite your hard drive.
- Unmount the card so no writes are happening while you read it.
- Use a disk imaging tool to copy the raw device to a file.
On Linux, you can use the dd command:
sudo dd if=/dev/sdb of=~/backup.img bs=4M status=progress
On macOS, you can use dd as well, but the device name will be something like /dev/rdisk2 (note the 'r' for raw device). On Windows, tools like Win32 Disk Imager or Rufus can create an image by selecting the card and choosing "Read" mode.
Why Create an Image Instead of Just Copying Files?
Simply copying files from an SD card to a folder does not preserve the boot sectors, partition layout, or file permissions. For a bootable card (like a Raspberry Pi OS), those hidden parts are essential. An image captures everything, so restoring it later produces a card that boots and behaves exactly like the original.
Also, an image is a single file, which makes it easy to store, compress, or transfer. You can compress an image with zip or gzip to save space, and you can verify its integrity with a checksum (like SHA-256) to ensure it wasn't corrupted.
How to Write an Image Back to an SD Card
Writing an image is the reverse process: you copy the image file to the raw device, overwriting the card's entire contents. This is often called "flashing" the card.
- Insert the target SD card and identify its device name (again, be careful).
- Unmount the card.
- Use a tool like
dd(Linux/macOS) or Win32 Disk Imager (Windows) to write the image to the device.
Example on Linux:
sudo dd if=~/backup.img of=/dev/sdb bs=4M status=progress
After writing, eject the card safely before removing it.
Common Problems and How to Avoid Them
The biggest risk when imaging an SD card is targeting the wrong device. A single typo in the device name can wipe your entire hard drive. Always double-check the device name using a tool like lsblk (Linux) or Disk Utility (macOS) before running dd.
Another issue is that the card may be mounted, causing the image to be inconsistent. Always unmount the card first. Also, some card readers introduce read errors; if you get an I/O error, try a different reader or a USB adapter.
Finally, be aware that an image of a larger card (e.g., 32 GB) will be 32 GB in size, even if only a small amount of data is used. You can shrink the image with tools like gparted or resize2fs to make it smaller, but that's an advanced operation.
How to Choose the Right Tool
For most users, a graphical tool is safer and easier than the command line. Here are some options:
- Windows: Win32 Disk Imager, Rufus, or Etcher
- macOS: Etcher, Apple Pi Baker, or the built-in
dd - Linux: Etcher, GNOME Disks, or the command-line
dd
Etcher (now BalenaEtcher) is cross-platform and has a simple interface: select the image, select the card, and click Flash. For creating an image (as opposed to writing one), Win32 Disk Imager has a "Read" mode that works well on Windows.
Frequently Asked Questions
Does creating an image erase the SD card?
No. Creating an image only reads data from the card; it does not modify or erase anything. The card remains exactly as it was. Writing an image, however, overwrites the card completely, so all existing data is lost.
Can I create an image of an SD card that is larger than my computer's RAM?
Yes. The image is written directly to your hard drive, not loaded into RAM. Tools like dd read and write in chunks, so the card size does not need to fit in memory. However, you need enough free space on your hard drive to store the image file.
How do I compress an SD card image?
You can compress the image file using standard compression tools like gzip or 7-Zip. For example, on Linux: gzip backup.img creates backup.img.gz. When you need to write it back, you can decompress it first, or use a tool like dd with a decompression pipeline: gzip -dc backup.img.gz | sudo dd of=/dev/sdb bs=4M.
Why does my image file have a different size than the card?
If you use a tool that only copies used space (like some backup utilities), the image may be smaller than the card. But a raw dd image will be exactly the size of the card (e.g., 32 GB for a 32 GB card). Some tools also compress the image automatically, which can reduce the file size.
Is it safe to use a USB card reader to create an image?
Yes, as long as the reader is reliable and the card is not being written to during the process. A USB reader is often safer than a built-in slot because it's easier to identify the correct device. Just make sure the reader supports the card type (SD, microSD, etc.).
Can I create an image of a card that is corrupted?
Sometimes. If the card is physically damaged or has bad sectors, the read may fail partway through. You can try using dd with the conv=noerror,sync option to skip bad sectors and fill them with zeros, but the resulting image may be incomplete. It's better to attempt a data recovery first if the card contains important data.