Skip to content

Instantly share code, notes, and snippets.

@justinmklam
Last active August 13, 2023 15:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinmklam/0a59c458420c56b821276a0d02e13b37 to your computer and use it in GitHub Desktop.
Save justinmklam/0a59c458420c56b821276a0d02e13b37 to your computer and use it in GitHub Desktop.
Backup SD card to file using dd

To find the partition, use the command:

$ df

The output will be something like below. In this case, the SD card is on /dev/mmcblk (ignore the two partitions).

Filesystem      Size  Used Avail Use% Mounted on
udev            7.8G     0  7.8G   0% /dev
tmpfs           1.6G  2.5M  1.6G   1% /run
/dev/nvme0n1p3  263G   36G  214G  15% /
tmpfs           7.8G  817M  7.0G  11% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/nvme0n1p2  515M  110M  406M  22% /boot/efi
tmpfs           1.6G   16K  1.6G   1% /run/user/118
tmpfs           1.6G   76K  1.6G   1% /run/user/1000
/dev/mmcblk0p1  253M   52M  201M  21% /media/jlam/boot
/dev/mmcblk0p2   15G  3.3G   11G  24% /media/jlam/rootfs

Execute the following to copy the SD card to an image file.

$ sudo dd if=/dev/mmcblk0 of=pi-backup.img status=progress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment