joefly
Posts: 64
Joined: Thu May 31, 2012 4:10 pm

Taking an image of the Rpi SD card

Sun Jul 01, 2012 8:53 pm

Hi,

I am wondering if there is a way to take a clone or image the SD card that we run on the RPI, so that if we screw something up, we can simply restore the previous image without having to going back to the initial Debian image.

I am hoping that there is something like Win32 DiskImager but in reverse. I am thinking something such as Acronis or Ghost on the windows platform

Thanks

JeremyF
Posts: 515
Joined: Wed Jan 25, 2012 9:06 pm
Contact: Website

Re: Taking an image of the Rpi SD card

Sun Jul 01, 2012 9:06 pm

Actually I think Win32DiskImager has this feature. The button marked "Read" should do this, but I'm not sure...
{sig} Setup: Original version Raspberry Pi (B, rev1, 256MB), Dell 2001FP monitor (1600x1200), 8GB Class 4 SD Card with Raspbian and XBMC, DD-WRT wireless bridge

User avatar
el_toro
Posts: 12
Joined: Sat Jun 30, 2012 10:26 pm

Re: Taking an image of the Rpi SD card

Sun Jul 01, 2012 9:14 pm

The way I did it was basically the reverse of the linux dd method which is how I back up my ubuntu laptop boot disk (to a 1TB USB drive) (for the laptop you boot from CD and reverse the dd)

1. Create a share on your favourite machine
On the Pi:
2. Mount it on the pi... mount myserver:/share /mnt
3. df -k and find the name of your boot device (/dev/mmblk0 for me)
4. sudo dd bs=1024 if=/dev/mmblk0 of=/mnt/pi_image_YYYYMMDD.img

There, that's it!

If you're using windys then step 2 you need to be a samba client, or alternatively bung in a USB stick, mount it e.g. to /mnt/usb and
4. sudo dd bs=1024 if=/dev/mmblk0 of=/mnt/usb/pi_image_YYYYMMDD.img

If you're making the cards in linux you can compress them to save space

4. sudo dd bs=1024 if=/dev/mmblk0 | gzip /mnt/pi_image_YYYYMMDD.img.gz


To put it back to a card (on your server)
fdisk -l (identify the card device, usually the last one but do make sure)
zcat <image name>.img.gz | dd bs=1024k of=/dev/sdzz

Bad Wolf
Posts: 66
Joined: Wed Jan 25, 2012 11:18 pm

Re: Taking an image of the Rpi SD card

Sun Jul 01, 2012 9:35 pm

As JeremyF said the button, marked "Read" in Win32DiskImager will copy the card as an image file for you.
To a person with a hammer, everything looks like a nail.

joefly
Posts: 64
Joined: Thu May 31, 2012 4:10 pm

Re: Taking an image of the Rpi SD card

Mon Jul 02, 2012 2:50 pm

Jeremy, Badwolf,

Thanks for the obvious solution, Duh! Thanks for bring it out to me. Sometimes the simplest answer is staring us in the face!

hiropro4
Posts: 5
Joined: Sun Sep 02, 2012 12:56 am

Re: Taking an image of the Rpi SD card

Thu Oct 11, 2012 4:28 am

For some reason, on my iMac, when I do the dd to copy and image, then dd it back to an SD card, the card won't boot. I can dd the initial images just fine. Missing something here...

User avatar
Dweeber
Posts: 606
Joined: Fri Aug 17, 2012 3:35 am
Location: Mesa, AZ
Contact: Website

Re: Taking an image of the Rpi SD card

Thu Oct 11, 2012 5:00 am

hiropro4 wrote:For some reason, on my iMac, when I do the dd to copy and image, then dd it back to an SD card, the card won't boot. I can dd the initial images just fine. Missing something here...
you do not say how you are using DD, but you need to be copying both partitions to make that work. Otherwise there is no boot partition which is the first FAT partition.
Dweeber A.K.A. Kevin...
My RPI Info Pages including Current Setup - http://rpi.tnet.com

Return to “Beginners”