Raspberry Pi SD Cloning

From Wurst-Wasser.net
Jump to navigation Jump to search

This article is about backupping and restoring the SD card of a Pi.

Installation

Linux

dd if=/home/h/Downloads/octopi-1.0.0-1.8.7-20230302160739.img of=/dev/mmcblk0 bs=1M

macOS

Since the Pi was running Debian Wheezy (which is AFAIK obsolete) I decided to install Raspbian Stretch.

I skipped NOOBS and did the installation myself (with help from https://www.raspberrypi.org/documentation/installation/installing-images/README.md and https://www.raspberrypi.org/documentation/installation/installing-images/mac.md ):

# diskutil list
[…]
/dev/disk5 (external, physical):
  #:                       TYPE NAME                    SIZE       IDENTIFIER
  0:     FDisk_partition_scheme                        *15.8 GB    disk5
  1:             Windows_FAT_32                         58.7 MB    disk5s1
  2:                      Linux                         15.8 GB    disk5s2
# diskutil unmountDisk /dev/disk5
Unmount of all volumes on disk5 was successful
# dd bs=1m if=2019-04-08-raspbian-stretch-lite.img of=/dev/rdisk5 conv=sync
5052+0 records in
5052+0 records out
5297405952 bytes transferred in 486.102151 secs (10897722 bytes/sec)
# diskutil eject /dev/rdisk5
Disk /dev/rdisk5 ejected
#


Backup

HeiMac:~ root# df -h | grep /Volumes
/dev/disk3s1    56Mi   19Mi   37Mi    34%    /Volumes/Untitled
HeiMac:~ root# 
HeiMac:~ root# umount /Volumes/Untitled 
HeiMac:~ root# dd if=/dev/rdisk3 of=/Users/heiko/Desktop/piBackup.img bs=1m

Restore

dd if=/Users/heiko/Desktop/piBackup.img of=/dev/rdisk3 bs=1m
umount /Volumes/Untitled 

If you restored on a SD card with with higher capacity, remember to use raspi-config to expand the filesystem.