clubmate.fi

A good[ish] website

Web development blog, loads of UI and JavaScript topics

How to clone Raspberry PI operating system

Filed under: System— Tagged with: shell, backup

I’ve been playing around with RPIs lately, and I’ve found it handy to take snapshots of my Micro SD card as I’m messing around, so that I’ve got backups when something inevitable goes wrong.

First, you need to find the device (the Micro SD card). To my understanding it’s always something like /dev/sdb or /dev/mmcblk0p1. For me it happens to be the latter.

My external drive hooked to the PI with a USB 3 cable occupies the name /dev/sda.

You can do an ls on the /dev (device) directory:

$ ls -l /dev

Then, check which drives are actually mounted currently:

$ df -h

You should see something like mmcblk0p1 or sda there.

Then make the image with dd:

$ sudo dd bs=4M if=/dev/mmcblk0p1

It’s smart to pipe that right into into gzip to save a bit of time:

$ sudo dd bs=4M if=/dev/mmcblk0p1 | gzip > raspbian.img.gz

Comments would go here, but the commenting system isn’t ready yet, sorry. Tweet me @hiljaa if you want to make a correction etc.

  • © 2021 Antti Hiljá
  • About
  • Follow me in Twatter → @hiljaa
  • All rights reserved yadda yadda.
  • I can put just about anything here, no one reads the footer anyways.
  • console.log('Smash the patriarchy!')
  • I love u!