Raspberry Pi OS Backup and Restore
OS Flashing¶
Pipettin OS¶
System images are uploaded to Google Drive, but not kept up-to-date frequently.
Once you download the image, you may flash it to a micro SD card as explained below.
Raspberry Pi OS¶
Download the Raspberry Pi OS from here.
Raspberry Pi OS Lite
Release date: May 3rd 2023
System: 64-bit
Kernel version: 6.1
Debian version: 11 (bullseye)
Size: 308MB
Flash the ISO¶
There are several ways to flash an ISO file to a micro SD card, here are the ones we have used.
Using Imager¶
Warning
This method works for new system images, we have not tested it for Pipettin OS images.
You may follow the
Using dd¶
Restore our SD card image to a 64 GB SD card using dd
from a Linux terminal.
We have used pishrink
on out system image, reducing it to 13 GB. You can use any card with 16 GB or more, yay!
Note:
- 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.
Details at: https://www.raspberrypi.org/documentation/linux/filesystem/backup.md
Steps:
- Insert the SD card into your computer.
- Run one of the commands 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
# Write images to the SD card.
# Replace "YOUR_SD_CARD_DEVICE" with your SD card's actual device name (you may use "lsblk" to find it).
# Use unzip for images compressed in zip format.
unzip -p pipettin_pi_pishrunk.img.zip | sudo dd bs=4M status=progress of=/dev/YOUR_SD_CARD_DEVICE && sync
# Use gunzip for images compressed in gz format.
gunzip --stdout pipettin_pi.img.gz | sudo dd bs=4M status=progress of=/dev/YOUR_SD_CARD_DEVICE && sync
# Use xz for Raspberry Pi images, compressed in xz format.
xz -dc 2023-05-03-raspios-bullseye-arm64-lite.img.xz | sudo dd of=/dev/YOUR_SD_CARD_DEVICE status=progress bs=4M conv=fsync
- Safely remove the SD card from your computer.
Next steps¶
- Insert it into your Raspberry Pi, and power it on.
- Configure a network connection.
- Access a terminal on the Raspberry.
- Check if the filesystem has expanded with
df -h
(Pipettin OS only).- If not expanded, reboot the Pi. It may take a couple reboots.
Utilities¶
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" to fill the new SD card during the first boot of the Pi, in a way similar to regular RPi OS images.
First install PiShrink on your system: https://github.com/Drewsif/PiShrink?tab=readme-ov-file#installation
You may then use the following commands to make a backup and shrink the image:
# 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