Skip to content

Raspberry Pi system image backup and restore

RPi System Images

Raspberry Pi OS flashing

Method 1: Burn the OS image

System images are uploaded to Google Drive, but not kept up-to-date frequently.

Once you flash the image to a micro SD card using the instructions below, plug it into your Raspberry Pi, and follow the update guides to get the latest software:

TO DO

Re-upload the ISO after cleaning it up with pishrink (see issues 198 and 32).

gunzip ISO

Restore our SD card image to a 64 GB SD card using dd and gunzip from a terminal.

  • Replace YOUR_SD_CARD_DEVICE above with the path to your SD card, found under /dev (for example /dev/sdx, as such, without the final slash).
  • To find the path to your SD card: unplug your card, then run lsblk, plug in your card, and run lsblk again, and compare the outputs. The new device should be your SD card.
  • Warning: If you get the path wrong, you may cause irreparable damage to your computer's filesystem.
# Replace "YOUR_SD_CARD_DEVICE" with your SD card's actual device name (you may use "lsblk" to find it).
gunzip --stdout pipettin_pi.img.gz | sudo dd bs=4M status=progress of=/dev/YOUR_SD_CARD_DEVICE
sync

Details at: https://www.raspberrypi.org/documentation/linux/filesystem/backup.md

pishrink ISO

We have used pishrink on out system image, reducing it to 13 GB. You can use any card with 16 GB or more, yay!

  1. Insert the SD card into your computer.
  2. Run the command below:
  3. Replace YOUR_SD_CARD_DEVICE above with the path to your SD card, found under /dev (for example /dev/sdx, as such, without the final slash).
  4. To find the path to your SD card: unplug your card, then run lsblk, plug in your card, and run lsblk again, and compare the outputs. The new device should be your SD card.
  5. Warning: If you get the path wrong, you may cause irreparable damage to your computer's filesystem.
# Replace "YOUR_SD_CARD_DEVICE" with your SD card's actual device name (you may use "lsblk" to find it).
unzip -p pipettin_pi_pishrunk.img.zip | sudo dd bs=4M status=progress of=/dev/YOUR_SD_CARD_DEVICE && sync
  1. Safely remove the SD card from your computer.
  2. Insert it into your Raspberry Pi, and power it on.
  3. Find its IP address, use ssh to log in, and check if the filesystem has expanded with df -h.
  4. If not expanded, reboot the Pi. It sometimes takes a couple boots.
  5. User and pass are the Pi's default.

Create OS backup image

Note: extra details at raspberrypi.org archive.

Using dd and gunzip

To create the compressed filesystem backup, we used:

# Replace "sda" with your SD card's actual device name (you may use "lsblk" to find it).
sudo dd bs=4M status=progress if=/dev/YOUR_SD_CARD_DEVICEYOUR_SD_CARD_DEVICE | gzip > pipettin_pi.img.gz
sync

Uncompressed (very large) images can be saved as well:

# Replace "sda" with your SD card's actual device name (you may use "lsblk" to find it).
sudo dd bs=4M status=progress if=/dev/YOUR_SD_CARD_DEVICE of=pipettin_pi.img
sync

Shrking images with PiShrink

A system image can be automatically shrunk using PiShrink. The main benefit is that the filesystem is also shrunk, so it can be used in SD cards smaller than the original.

The image will "auto-expand" in a way similar to regular RPi OS images.

# Do a compressed backup before shrinking, just in case!
gzip -k pipettin_pi.img

# Shrink the image with PiShrink
sudo pishrink.sh pipettin_pi.img

# Compress the shrunk image, for sharing.
zip pipettin_pi.img.zip pipettin_pi.img