gnosticpi
Posts: 4
Joined: Fri Sep 14, 2012 8:07 am

Problems creating a backup of my sd-card

Fri Sep 14, 2012 8:15 am

After having spent a few hours on installing what I want to run on my Pi I wanted to create a backup of my SD card so in case I screw something up while doing further experiments I dont have to start from square one.

I tried to reverse the dd command I used to flash the original image to the sd card by exchanging the if= and the of= in the hope that it would read from the sd and write an image file on my harddisk

dd bs=1M of=~/my-backup-image.img if=/dev/sdd

Somehow I get read errors when doing so. I'm using the same sd card reader I used to flash this sd card. Is my usage of the command wrong or is it possible that my sd-card reader could write an SDHC card but might have trouble reading from it ?

Thanks for any hints

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Problems creating a backup of my sd-card

Fri Sep 14, 2012 10:17 am

I don't know much about dd, but I think the syntax is something like this...

Code: Select all

dd if=/dev/sdX of=/path/to/backupfile.img
where sdX is your SD card and /path/to/backupfile.img is the file you want to save to. Have you got them (if and of) the wrong way round perhaps? Your of is before your if. Perhaps that is confusing the computer as it needs an input file before it can write an output file?

You have to be a bit careful with dd. It's nicknamed Destroy Disk for a good reason. That's one of the reasons I prefer doing this on Windows (it's good for something after all :lol: )

If you have a windows box, you could do it with win32diskimager

http://raspi.tv/2012/back-up-your-raspberry-pi-sd-card
Alex Eames RasPi.TV, RasP.iO

User avatar
RaTTuS
Posts: 10539
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Problems creating a backup of my sd-card

Fri Sep 14, 2012 10:36 am

dd bs=1M if=/dev/sda of=/path/to/backup.img conv=sync,noerror
you may need sync and noerror if there are any problems on the SD card -
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

kaspencer
Posts: 86
Joined: Wed Mar 07, 2012 11:37 pm
Location: UK, England, Wiltshire

Re: Problems creating a backup of my sd-card

Tue Sep 25, 2012 9:59 am

Greeting Pi-ers ...

I have been using Win32DiskImager.exe to back up my 64Gbyte SD Card, having spent hours setting up over 60Gbyte of music and video onto the Pi. I am about to upload to a second SD Card (32Gbyte to give me 96Gbyte of my favourite Music & Video ...

Using Win32DiskImager to backup appears to be quite simple: just slot your SD Card into a suitable adapter (not all USB SD adapters can handle 64Gbyte SD cards though - I installed one of the those USB internal 3.5" floppy drive size multi-card readers - use the Win32DiskImager "Read" option (which it states clearly will write a copy of the SD device image to a file on the local PC filing system), and give it a suitable filename & location.

However, and here's another possible question for Rattus (I owe him/her a pint): why are all my 64Gbyte SD output files from Win32DiskImager the same size, (4,194,304kb) regardless of the amount of data on the SD disc? Am I deluding myself that I am getting a valid backup? I haven't got a spare 64Gbyte SD card to attempt a restore on!

Thanks in advance ...

Ken
2xRPi 1, 2xRPi 2, 2xRPi4.
KODI: on RPi 2.
Webserver: on RPi 2.
PDC & fileserver: 4TB disc +RiscOS Pi on RPi 2 + 4.
Book: All about your computer - http://goo.gl/ZQf7c7

ghans
Posts: 7882
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Problems creating a backup of my sd-card

Tue Sep 25, 2012 10:24 am

That is one special quality of a raw disk image : it is pretty raw.
A disk image does not care for partitions , bootloader or filesystems. Therefore
it also copies free space. If you want to save space , compress it.
My image is uncompressed about 16 GB , compressed only about 2 GB .
That means the program "sees" the 14 GB free space and collapses them effortlessly.


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Wisar
Posts: 60
Joined: Tue Sep 25, 2012 6:33 am
Location: Temple near Marlow, England
Contact: Website

Re: Problems creating a backup of my sd-card

Tue Sep 25, 2012 1:45 pm

Win32DiskImager only saw the first, small, partition on my SD card ignoring the other 15+Gb where all the good stuff is. Am I missing something. I would really like to have a backup of my SD card now that things are pretty well configured!

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Problems creating a backup of my sd-card

Tue Sep 25, 2012 1:53 pm

Wisar wrote:Win32DiskImager only saw the first, small, partition on my SD card ignoring the other 15+Gb where all the good stuff is. Am I missing something. I would really like to have a backup of my SD card now that things are pretty well configured!
Are you sure about this? Windows itself should only "see" the FAT partition on the SD card, but the Win32DiskImager program should be able to access the whole card for backup purposes.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

Boomer
Posts: 80
Joined: Thu Sep 06, 2012 3:22 pm

Re: Problems creating a backup of my sd-card

Tue Sep 25, 2012 2:02 pm

FWIW, I believe the User Guide says that you can't use the Windows utility to do this, but I did notice the read command and was thinking of doing this myself. May be an updated feature of the utility.

Wisar
Posts: 60
Joined: Tue Sep 25, 2012 6:33 am
Location: Temple near Marlow, England
Contact: Website

Re: Problems creating a backup of my sd-card

Tue Sep 25, 2012 2:07 pm

Just tried it again. The read finished in almost no time and only wrote a 57mb file...which I assume is the boot? It worked great going the other way when I first created my card!

User avatar
with ice cream
Posts: 175
Joined: Mon Jul 30, 2012 7:25 am

Re: Problems creating a backup of my sd-card

Tue Sep 25, 2012 3:19 pm

Search for (the Windows program) "HDD Raw Copy Tool" - its images are compressed.

with Ice cream

Wisar
Posts: 60
Joined: Tue Sep 25, 2012 6:33 am
Location: Temple near Marlow, England
Contact: Website

Re: Problems creating a backup of my sd-card

Tue Sep 25, 2012 5:07 pm

Similar issue as before...only the boot partition is seen. It seems like Clonezilla might be my best option but I am having trouble with it as well. My SD card runs perfectly on the RPI but it does seem like I am struggling where others have not?

kaspencer
Posts: 86
Joined: Wed Mar 07, 2012 11:37 pm
Location: UK, England, Wiltshire

Re: Problems creating a backup of my sd-card

Tue Sep 25, 2012 7:51 pm

Well, the behaviour of Win32DiskImage when I copied my 64Gbyte SD card was completely different from that experienced by W.

For one thing, it took an hour to make the copy - and that makes it unlikely that it copied only the FAT (/boot) partition of the SD card.

For another, the size - 4Gbyte plus, is too big for the /boot partition, which I think I remember as being only a few tens of Mbyte.

My confusion is that the size of the copied SD image is always 4Gbyte and a bit - regardless of what I put in the main partition! But I haven't got a spare 64Gbyte SD Card on which to test a "restore" operation.

Keep up the investigations ...

All the best

Ken
2xRPi 1, 2xRPi 2, 2xRPi4.
KODI: on RPi 2.
Webserver: on RPi 2.
PDC & fileserver: 4TB disc +RiscOS Pi on RPi 2 + 4.
Book: All about your computer - http://goo.gl/ZQf7c7

User avatar
PIstolero
Posts: 101
Joined: Mon Jul 23, 2012 6:28 am
Location: paradise city, where the grass is green and the girls are pretty

Re: Problems creating a backup of my sd-card

Tue Sep 25, 2012 7:56 pm

Are you using a FAT32 filesystemto store the image (4GB limitation)?

kaspencer
Posts: 86
Joined: Wed Mar 07, 2012 11:37 pm
Location: UK, England, Wiltshire

Re: Problems creating a backup of my sd-card

Tue Sep 25, 2012 8:33 pm

Reply to P: I am using an NTFS volume for image file on a Windows Vista Ultimate x64 core2 quad PC with 16 Gbyte RAM.

Maybe that helps, but somehow I doubt it!

Ken
2xRPi 1, 2xRPi 2, 2xRPi4.
KODI: on RPi 2.
Webserver: on RPi 2.
PDC & fileserver: 4TB disc +RiscOS Pi on RPi 2 + 4.
Book: All about your computer - http://goo.gl/ZQf7c7

Wisar
Posts: 60
Joined: Tue Sep 25, 2012 6:33 am
Location: Temple near Marlow, England
Contact: Website

Re: Problems creating a backup of my sd-card

Wed Sep 26, 2012 8:39 am

Finally have a backup...and on a slightly faster SD card as well. I somehow doubt that this was the easiest way to accomplish this but here is what I did:

First, on a laptop running Ubuntu...created an image of each of the two partitions on the SD card that I want to backup (could be done on the RPI with another place to stick an SD card:
sudo dd if=/dev/[SD Card Partition 1] of=RPIpart1.img
sudo dd if=/dev/[SD Card Partition 2] of=RPIpart2.img

Second, created a bootable target SD card of the same size as the one I wish to backup.

Third, booted the above on the RPI and expanded the partition (no other customizations after the reboot for the expand)

Inserted the target SD card from above and reversed the DD step.

It works but not exactly the single step operation that I was hoping for!

Wisar

luboss
Posts: 8
Joined: Mon Aug 20, 2012 12:36 pm

Re: Problems creating a backup of my sd-card

Mon Oct 15, 2012 9:12 am

Wisar, that means that you solved it only with linux :-(

I suffer the same problems with copying only first partition of a card on Windows. I tried Win32DiskImager, HDD Raw Copy Tool and dd for windows but without success. I have card reader only on one of my PCs and I don't want to use linux on it for a reason.
I'll try to get around this with Linux on VirtualBox but if I fail I will be forced to buy USB card reader :|

Tanga
Posts: 30
Joined: Tue Jan 03, 2012 11:18 pm

Re: Problems creating a backup of my sd-card

Sat Oct 20, 2012 11:46 pm

Hey luboss - I thought I was having the same trouble, but it turns out that Disk Imager is less intuitive than it could be. This walkthrough was great:
http://raspi.tv/2012/back-up-your-raspberry-pi-sd-card
Raspberry Pi (Raspbian) Tutorials by a fellow noob:
http://noobsquared.blogspot.com.au/

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

Re: Problems creating a backup of my sd-card

Sun Oct 21, 2012 2:40 am

I make backups of my images all the time. The key for me was to start out on the right track...

o Start with the distro image
o Write it to an SDCard
o Run it in an RPi but DON'T use the expand option that raspi-config offers.
o Instead use rpi-wiggle which does the same thing, but backs off a bit rather than using the entire full disk.
o Backup the image using Win32diskimage....
o Write the new backup image to whatever SDcards you want to...

I do backups whenever there is some major change or I want to mirror an image to multiple devices.

I just did a new master after updating with the newest Firmware that supports the new memory conf via config.txt (no more bunch of start elf files). I am in the process of writing out duplicate images for the other two devices now all of the master that I backed up earlier this evening.

Ref:
Using Rpi-Wiggle - http://rpi.tnet.com/project/scripts/rpi-wiggle
Backing up an image using Win32diskimage - http://rpi.tnet.com/project/faqs/backups/backingup

Note if you use the raspi-config expand you can end up with the following error if you try to write a backed up image a new card.

Image

A sad error... which can only be gotten around by doing a lot of work in Linux.
Dweeber A.K.A. Kevin...
My RPI Info Pages including Current Setup - http://rpi.tnet.com

luboss
Posts: 8
Joined: Mon Aug 20, 2012 12:36 pm

Re: Problems creating a backup of my sd-card

Thu Oct 25, 2012 9:43 am

I solved this issue by not using preferred Win32DiskImage to write the image to card but win-dd instead:
http://www.chrysocome.net/dd

So the trick is not just in how to read the image from card but first of all in writing the image.

Afterwards I used windows dd again to read the image from card and vou alla it works perfectly. You have to put "bs=1M count=2048" (or something like that) to not read the whole card (if you did not expand the rootfs).

Return to “Beginners”