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.
- Folder: https://drive.google.com/drive/folders/1cs03XJp5RM0zdT_pLNfuJ14q0rI2-7gj
- Latest image (requires a 64 GB micro SD card): https://drive.google.com/drive/folders/1cs03XJp5RM0zdT_pLNfuJ14q0rI2-7gj?usp=drive_link
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:
- Software updates.
- General software setup instructions.
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 runlsblk
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!
- Insert the SD card into your computer.
- Run the command below:
- 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 runlsblk
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).
unzip -p pipettin_pi_pishrunk.img.zip | sudo dd bs=4M status=progress of=/dev/YOUR_SD_CARD_DEVICE && sync
- Safely remove the SD card from your computer.
- Insert it into your Raspberry Pi, and power it on.
- Find its IP address, use
ssh
to log in, and check if the filesystem has expanded withdf -h
. - If not expanded, reboot the Pi. It sometimes takes a couple boots.
- 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