Raspberry Pi – How to clone your boot chip and backup your system

Basically, I came to the conclusion that I needed to use my Linux Desktop to do a clone of my Raspberry Pi.  Windows has different tools, Mac has some of the same tools and I believe dd is available under terminal.

 

I’m not a Mac or Windows Guy, I use Debian Linux, exclusively.

The lay of the land is

  • Host Computer running Linux
  • Sufficient space on the internal hard drive
  • A chip reader to connect the chip to the USB chain of the host computer

So you have a credit card sized computer.  The little computer that could.

You decided to do some things to it and perhaps got your feet wet using Linux.

Good for you.  That’s one good use for a Raspberry Pi.

It’s a machine that is best used for learning.  Doing weird projects like you see all over the place.

I have the second “use case” for it here.  It’s a great Print Server.  I turn it on, my Linux desktop sees it, and I can print to it.

All that requires some customization of the machine, installing CUPS, maybe some other things like using it as a small data server with SAMBA.

You got your machine stable but did you back it up?

After all, if you’re playing with RTL-SDR and want to look at some amateur radio using the Pi to serve the radio out from where the antenna is, it will take more customization that you won’t want to lose.

Ok, so since the Raspberry Pi can run off a couple rechargeable batteries or a wall wart, it’s getting put out in the shed and is now nice and stable but the second situation comes to mind for backing it up.

Debian and Raspbian will be upgraded to the next version “very soon”.  There’s no rush for that, the old stable will be maintained for a few years, I mean Linux isn’t managed like Windows is, is it?

Even though the next version, Testing, is stable enough to use as a daily driver like I do, you really do want to back that machine before you upgrade in case you do it wrong.

One final reason to back up is that the Raspberry Pi occasionally corrupts the litlle SDHC chip that has the Operating System on it due to static electricity, power pops and so forth.  That is how the hardware is constructed, you can’t avoid power instability without filters or battery backups.

Get the picture?

Here is how I do a backup, and when I am done, I have an .ISO file that I can write out to a different chip.

  • First shut down and power off the Pi.
  • Remove the Pi’s Boot Chip and put it in your USB Chip Reader.
  • Make sure your Linux Host Computer is turned on, and booted.
  • Navigate to the directory you want to store your .ISO image with Terminal under Root.
  • Plug the USB Chip Reader with the chip into the USB Port.
  • From the Root Prompt run “dmesg“.  dmesg will scroll very quickly all the console information, but what you are looking for is a message that says that you plugged in something to /dev/sdb or similar.  In my case, it came up on /dev/sdd .  The messages that I got when I plugged the chip in are below.

[132387.203934] usb 3-2: new SuperSpeed Gen 1 USB device number 8 using xhci_hcd
[132387.224573] usb 3-2: New USB device found, idVendor=05e3, idProduct=0749, bcdDevice=15.32
[132387.224577] usb 3-2: New USB device strings: Mfr=3, Product=4, SerialNumber=2
[132387.224579] usb 3-2: Product: USB3.0 Card Reader
[132387.224580] usb 3-2: Manufacturer: Generic
[132387.224582] usb 3-2: SerialNumber: 000000001532
[132387.227673] usb-storage 3-2:1.0: USB Mass Storage device detected
[132387.263161] scsi host2: usb-storage 3-2:1.0
[132388.282897] scsi 2:0:0:0: Direct-Access     Generic  STORAGE DEVICE   1532 PQ: 0 ANSI: 6
[132388.286984] sd 2:0:0:0: Attached scsi generic sg3 type 0
[132388.679099] sd 2:0:0:0: [sdd] 31116288 512-byte logical blocks: (15.9 GB/14.8 GiB)
[132388.679447] sd 2:0:0:0: [sdd] Write Protect is off
[132388.679450] sd 2:0:0:0: [sdd] Mode Sense: 21 00 00 00
[132388.679775] sd 2:0:0:0: [sdd] Write cache: disabled, read cache: enabled, doesn’t support DPO or FUA
[132388.686945]  sdd: sdd1 sdd2 < sdd5 sdd6 sdd7 >
[132388.688860] sd 2:0:0:0: [sdd] Attached SCSI removable disk

  • The command to do the backup is a simple dd command.  This command will be creating a file called raspberrypibackup.iso in the present working directory.  Assuming your linux host saw the USB stick as /dev/sdb the command is following:

dd if=/dev/sdb of=raspberrypibackup.iso conv=noerror,sync status=progress


Really that is it.  Just issue that command, walk away.  It took about an hour for me to do this al, plenty of time to do something else.

Or just go have a coffee.

When it is complete you will have your backup ISO and you can copy that back out to a chip or just leave the file on your hard disc as an archive.

The restore is the same dd command with the if and of parameters swapped:

dd if=raspberrypibackup.iso of=/dev/sdb conv=noerror,sync status=progress

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.