Nb8k
Posts: 11
Joined: Tue May 15, 2012 8:34 pm

Backup SD

Tue May 15, 2012 8:40 pm

Now I have got my SD card set up properly with the correct wifi drivers etc on Debian 19-04, what is the easiest way to create an identical bootable SD card? I have already had to start from the beginning a few times when something has gone wrong. I have an Ubuntu machine and win7 available to do this if needed.
I have seen a few discussions similar to this but no clear option recommended.

Thanks in advance,

stevepdp
Posts: 285
Joined: Fri Oct 28, 2011 7:41 am

Re: Backup SD

Tue May 15, 2012 8:52 pm

I would recommend looking into the "dd" command on your Ubuntu installation, but be incredibly careful with it as it has the potential to destroy data if used incorrectly. Backup first! :-)

In general, the command is used like so, where DISK is the device name such as sdc and where YOURUSER is your username:

Code: Select all

sudo dd if=/dev/DISK of=/home/YOURUSER/backup.img
This example would backup your stick to your home directory. You would then write the image back to another stick with a command like:

Code: Select all

sudo dd if=/home/YOURUSER/backup.img of=/dev/DISK
For more specific details, see the man page for dd, or look it up on the Ubuntu wiki.

Let us know how you get on.

User avatar
dhardingham
Posts: 28
Joined: Mon Jan 02, 2012 12:45 pm
Location: Stevenage, UK
Contact: Website

Re: Backup SD

Tue May 15, 2012 8:53 pm

I use the Windows Win32DiskImager program to read everything off my SD card and store it in a .img file. I can then write this to a different SD card, if I ever need to :D
David Hardingham

Nb8k
Posts: 11
Joined: Tue May 15, 2012 8:34 pm

Re: Backup SD

Tue May 15, 2012 9:02 pm

Thanks for both these replies , I will try both your suggestions and report back.

Nb8k
Posts: 11
Joined: Tue May 15, 2012 8:34 pm

Re: Backup SD

Tue May 15, 2012 9:19 pm

dhardingham wrote:I use the Windows Win32DiskImager program to read everything off my SD card and store it in a .img file. I can then write this to a different SD card, if I ever need to :D
I just tried this method but it only created a 77mb image file. How do you get it to read all partitions?

Update: This issue was resolved by using a USB card reader instead of the built-in one on my laptop.

User avatar
grumpyoldgit
Posts: 1453
Joined: Thu Jan 05, 2012 12:20 pm

Re: Backup SD

Tue May 15, 2012 9:33 pm

You have only backed up the FAT partition.
When I insert my SD card into the reader it is identified as SDD.
However, the Ubuntu disk utility gives more information than that. It identifies the FAT partition as SDD1 and the ext4 partition as SDD2.
What did you call your drive in the DD command?

Nb8k
Posts: 11
Joined: Tue May 15, 2012 8:34 pm

Re: Backup SD

Tue May 15, 2012 9:36 pm

The problem was experienced when using the windows disk imager. It was resolved by using a USB card reader instead of the inbuilt laptop reader. I haven't tried the dd method yet.
-Thanks

User avatar
grumpyoldgit
Posts: 1453
Joined: Thu Jan 05, 2012 12:20 pm

Re: Backup SD

Tue May 15, 2012 9:42 pm

I thought you had a Ubuntu PC.

Nb8k
Posts: 11
Joined: Tue May 15, 2012 8:34 pm

Re: Backup SD

Tue May 15, 2012 9:51 pm

I have both Ubuntu and win7. I thought I would try the "safer" method first! However, I'm keen to get comfortable with using dd now, so will give that a go next.

MrEngman
Posts: 3700
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: Backup SD

Thu May 17, 2012 12:34 pm

Nb8k wrote:
dhardingham wrote:I use the Windows Win32DiskImager program to read everything off my SD card and store it in a .img file. I can then write this to a different SD card, if I ever need to :D
I just tried this method but it only created a 77mb image file. How do you get it to read all partitions?

Update: This issue was resolved by using a USB card reader instead of the built-in one on my laptop.
A word of warning. This may not always be possible. :( Not easily anyway.

I have been reading back the partion data so if I break something I can re-write the disk and get back to a usable SD. I tried to write the saved image to different SD card, using Win32diskimager, and got a message "Not enough space on disk". Both SD cards I am using are Sandisk 16GB so I thought would be the same capacity. Turns out one, the one I read the original image from, has a slightly greater capacity than the second SD card and the image from the first SD card was too big to fit on the second one even though they were both supposedly the same capacity.

Reading the image from one SD card gave a size of 15,633,408KB and the other gave a size of 15,558,144KB. A difference in capacity of 75264KB.

At some stage I would like to find some way of altering the image sizes so they all fit on both SD cards but as they contain Linux partitions, which windows doesn't normally see, I'm not sure how to at the moment. Just need to investigate the many partition management programs I guess - what a pain.

Hopefully you won't have the same problem.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

User avatar
RaspberryPiBeginners
Posts: 218
Joined: Fri May 11, 2012 6:54 am
Location: Soham, Cambridgeshire
Contact: Website

Re: Backup SD

Thu May 17, 2012 12:53 pm

dhardingham wrote:I use the Windows Win32DiskImager program to read everything off my SD card and store it in a .img file. I can then write this to a different SD card, if I ever need to :D
I'm not sure if mine went wrong but i tried Win32DiskImager, and i wasn't able to restore it but might have been bad luck. Really need a spare card to try swapping the image into.
Click here for my unofficial YouTube Channel > http://goo.gl/oFYBD

trikidiki
Posts: 12
Joined: Thu Mar 15, 2012 9:00 pm

Re: Backup SD

Tue May 22, 2012 7:54 pm

MrEngman wrote: .................................................

Reading the image from one SD card gave a size of 15,633,408KB and the other gave a size of 15,558,144KB. A difference in capacity of 75264KB.

...............................................
Hopefully you won't have the same problem.
I had a similar problem where someone posted an 8Gb image for OpenElec. I tried loading it onto my 8Gb SD card but it failed saying I was a few thousand kb short of space. It seems not all SD cards have the same capacity.

User avatar
grumpyoldgit
Posts: 1453
Joined: Thu Jan 05, 2012 12:20 pm

Re: Backup SD

Tue May 22, 2012 7:58 pm

Just reduce the size of the Linux partition slightly with Gparted or similar.

MrEngman
Posts: 3700
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: Backup SD

Tue May 22, 2012 11:05 pm

grumpyoldgit wrote:Just reduce the size of the Linux partition slightly with Gparted or similar.
gparted can change the partion sizes BUT it makes no difference when using Win32DiskImager to write and read images. I use Win32DiskImager to write and read my SD card images. When saving an image from an SD card Win32DiskImager, as far as I can tell, reads the complete SD card regardless of what is on it, valid partitions or blank/unused space, so you get an image the size of the card. If you then try and copy the image to another SD card that is any smaller than the original one Win32diskimager complains about insufficient space and will not write it. Using dd (Windd) to write the image to a slightly smaller SD card may work as if I remember correctly dd, not sure about Windd but I guess it should work the same way, takes no notice of the size of where it is copying to until it actually runs out of space and then it complains of course. If the end of the image is unused space then using dd will write the image and fail at the end because of insufficent space on the smaller SD card but provided the part of the image not written contains only unused space and not part of any valid partition then the newly written SD card should be perfectly OK to use.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

fulvio
Posts: 17
Joined: Tue Sep 25, 2012 5:29 am

Re: Backup SD

Wed Oct 17, 2012 5:46 am

Did someone resolve the issue with capacity of different SD cards?

I'm having the same problem migrating an image originally backed up from a Sandisk SDHC 8gb and restoring to a Micro SDHC 8gb (I'm using a ModMyPi SD to Micro SD converter).

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Backup SD

Wed Oct 17, 2012 6:04 am

The basic steps to get around the SD card capacity issue is to use Gparted on a Linux setup to reduce the size of the ext4 partition a bit (say 0.5G), then use dd to make an image of it then swap to smaller card and use dd to put this image onto the smaller card.

You will get an error msg at the end of the process that says that dd couldn't write the whole image to the new card but it doesn't matter.

You can test out your new smaller SD card and make sure everything is fine.

And then - stick with using the smaller SD card as your master copy and you can then use WinDiskImager in future to make backup copies of it that should fit on any SD card of the same stated capacity

regards

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

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

Re: Backup SD

Wed Oct 17, 2012 9:04 am

Does that actually work though unless you copy the partitions separately?

You can shrink the partitions on an SD card with Parted/GParted but when you image the card, doesn't it copy the empty space as well?

I had to reinstall Ubuntu last week because my system got messed up when I accidentally filled the hard disk when doing a DD from a 32 Gig SD card with a 2 Gig image on it. :lol:
Alex Eames RasPi.TV, RasP.iO

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Backup SD

Wed Oct 17, 2012 9:44 am

You can shrink the partitions on an SD card with Parted/GParted but when you image the card, doesn't it copy the empty space as well?
What you are doing is making he total of the 2 partitions fit well inside the "same" sized SD card.

When you use dd to write this image back to a smaller card - the extra bytes don't fit - you get an error - but the error doesn't matter.

Then, when you use win32diskimager to take an image of the smaller card, you now have an image that will fit on any card that is at least the same size as the smaller card :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

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

Re: Backup SD

Wed Oct 17, 2012 10:21 am

simplesi wrote:
You can shrink the partitions on an SD card with Parted/GParted but when you image the card, doesn't it copy the empty space as well?
What you are doing is making he total of the 2 partitions fit well inside the "same" sized SD card.

When you use dd to write this image back to a smaller card - the extra bytes don't fit - you get an error - but the error doesn't matter.
That's the bit I missed. I didn't bother checking to see if the "errored" card actually worked. No need to mess about doing separate partitions then. 8-) I'll try that later.
Alex Eames RasPi.TV, RasP.iO

clipper
Posts: 6
Joined: Mon Oct 01, 2012 1:46 pm

Re: Backup SD

Wed Oct 17, 2012 5:49 pm

I've just made a backup copy of the 4GB SD card supplied with my RPi from Maplin.

I used Win32diskimager and the 'img' file created is about 4GB. I thought it might create a file containing only the space actually used on the card, but it seems to have included 'empty' SD card space.

If I later restore the img file to a new 16GB SD card, does it matter that the img file size is 12GB less than the capacity of the new card?
Will I still be able to use this extra 12GB for programs/data storage etc?

Thanks

clipper

simplesi
Posts: 2327
Joined: Fri Feb 24, 2012 6:19 pm
Location: Euxton, Lancashire, UK
Contact: Website

Re: Backup SD

Wed Oct 17, 2012 9:14 pm

Will I still be able to use this extra 12GB for programs/data storage etc?
No and Yes :)
At the start - no - but you can just use raspi-config to expand the main partition to fill the card :)

Simon
Seeking help with Scratch and I/O stuff for Primary age children
http://cymplecy.wordpress.com/ @cymplecy on twitter

clipper
Posts: 6
Joined: Mon Oct 01, 2012 1:46 pm

Re: Backup SD

Thu Oct 18, 2012 2:17 pm

Thanks Simon,

I'll buy a 16GB card now I know I can use it fully.

Wanderlei
Posts: 79
Joined: Tue Aug 21, 2012 2:01 pm

Re: Backup SD

Sat Oct 20, 2012 2:18 pm

I get a error at the start before it has written any data with Win 32 Dsik Imager.

I have 4GB image but it is really only a 1GB setup of xbmc and I wanted to copy to a 2GB card. I thought this trick would work but unfortunately not unless I miss something.

User avatar
JaiBo
Posts: 3
Joined: Mon Sep 03, 2012 10:39 pm
Location: UK

Re: Backup SD

Tue Nov 13, 2012 10:46 am

Thanks this helped me backup my openelec XBMC SD card for my RPi on my Ubuntu partitions Home folder.

Just a note, my SD card was named :-

Code: Select all

/dev/mmcblk0
Who ate all the Pi's?

User avatar
Thijxx
Posts: 86
Joined: Mon Oct 22, 2012 1:25 pm
Location: The Netherlands

Re: Backup SD

Tue Nov 13, 2012 1:33 pm

This looks clear but I wonder what the right 'dev' is because if I do a 'df' command or I list the /dev contents, there are loads of things in there.

My goal is to have a 'ready-to-write' image of the SD card so I can recover/copy the whole Pi in a couple of minutes.

Code: Select all

[email protected]:/dev# ls
autofs           loop6               ram14    tty10  tty30  tty50      usbdev1.1
block            loop7               ram15    tty11  tty31  tty51      usbdev1.2
btrfs-control    loop-control        ram2     tty12  tty32  tty52      usbdev1.3
bus              MAKEDEV             ram3     tty13  tty33  tty53      vchiq
cachefiles       mapper              ram4     tty14  tty34  tty54      vc-mem
char             mem                 ram5     tty15  tty35  tty55      vcs
console          mmcblk0             ram6     tty16  tty36  tty56      vcs1
cpu_dma_latency  mmcblk0p1           ram7     tty17  tty37  tty57      vcs2
disk             mmcblk0p2           ram8     tty18  tty38  tty58      vcs3
fb0              net                 ram9     tty19  tty39  tty59      vcs4
fd               network_latency     random   tty2   tty4   tty6       vcs5
full             network_throughput  raw      tty20  tty40  tty60      vcs6
fuse             null                root     tty21  tty41  tty61      vcsa
input            ppp                 shm      tty22  tty42  tty62      vcsa1
kmsg             ptmx                snd      tty23  tty43  tty63      vcsa2
log              pts                 sndstat  tty24  tty44  tty7       vcsa3
loop0            ram0                stderr   tty25  tty45  tty8       vcsa4
loop1            ram1                stdin    tty26  tty46  tty9       vcsa5
loop2            ram10               stdout   tty27  tty47  ttyAMA0    vcsa6
loop3            ram11               tty      tty28  tty48  ttyprintk  xconsole
loop4            ram12               tty0     tty29  tty49  uinput     zero
loop5            ram13               tty1     tty3   tty5   urandom

Code: Select all

[email protected]:/dev# df
Filesystem              1K-blocks      Used Available Use% Mounted on
rootfs                    7579104   3984488   3209768  56% /
/dev/root                 7579104   3984488   3209768  56% /
devtmpfs                   224436         0    224436   0% /dev
tmpfs                       44900       236     44664   1% /run
tmpfs                        5120         0      5120   0% /run/lock
tmpfs                       89780         0     89780   0% /run/shm
/dev/mmcblk0p1              57288     16920     40368  30% /boot
stevepdp wrote:I would recommend looking into the "dd" command on your Ubuntu installation, but be incredibly careful with it as it has the potential to destroy data if used incorrectly. Backup first! :-)

In general, the command is used like so, where DISK is the device name such as sdc and where YOURUSER is your username:

Code: Select all

sudo dd if=/dev/DISK of=/home/YOURUSER/backup.img
This example would backup your stick to your home directory. You would then write the image back to another stick with a command like:

Code: Select all

sudo dd if=/home/YOURUSER/backup.img of=/dev/DISK
For more specific details, see the man page for dd, or look it up on the Ubuntu wiki.

Let us know how you get on.
Mimi: Where'd you come from?
Doyle: My mom and the authorities are still trying to figure that out.

Return to “Beginners”

Who is online

Users browsing this forum: fbe, lmarmisa and 30 guests