Creating an image file of my pi


15 posts
by StoopKid » Fri Jan 04, 2013 2:06 am
I only have my pi and windows 7 machines. How can I make a new image of my pi setup so that next time I write the image to a card I will be set up how I am now? I have seen a few threads on the subject but they require a mac.

Thanks.
Posts: 38
Joined: Thu Jul 19, 2012 5:41 am
by StoopKid » Fri Jan 04, 2013 2:16 am
Oh jeez, and of course 5 seconds later I find the answer. win32diskimager appears to have a "reverse" so that seems to be what I want.

But can I verify that this will give me what I want?

Thanks
Posts: 38
Joined: Thu Jul 19, 2012 5:41 am
by azeam » Fri Jan 04, 2013 2:28 am
Yes
User avatar
Posts: 192
Joined: Fri Oct 26, 2012 11:13 pm
by StoopKid » Fri Jan 04, 2013 2:31 am
Actually now I do have a tiny problem. I purposely did not re size the partition yet so that the image could stay small but that program still makes the image from my whole 8gb card. Is there any way to fix this especially since I may want to use a smaller card in the future?

Thanks.
Posts: 38
Joined: Thu Jul 19, 2012 5:41 am
by excollier » Fri Jan 04, 2013 8:30 am
I tried Win32diskimager to back up my card image but it refused to do it saying something about "not able to get a handle" on the image or such like, and "unable to lock" or something similar, I had to give up and get back to living.
User avatar
Posts: 192
Joined: Wed Sep 12, 2012 8:17 am
by azeam » Fri Jan 04, 2013 12:45 pm
StoopKid wrote:Actually now I do have a tiny problem. I purposely did not re size the partition yet so that the image could stay small but that program still makes the image from my whole 8gb card. Is there any way to fix this especially since I may want to use a smaller card in the future?

Thanks.


I haven't used Win32Diskimager but afaik it works the same way as dd, which is reading the disk at a very low level (including empty space). Therefore it is not possible to make the image any smaller than the card itself.
User avatar
Posts: 192
Joined: Fri Oct 26, 2012 11:13 pm
by Joe Schmoe » Fri Jan 04, 2013 1:17 pm
I haven't used Win32Diskimager but afaik it works the same way as dd, which is reading the disk at a very low level (including empty space). Therefore it is not possible to make the image any smaller than the card itself.


(Channelling Mittens) Of course it is!

You just have to work at the partition level rather than at the "whole disk" level.

Instead of:

Code: Select all
dd if=/dev/sda ...


do:

Code: Select all
dd if=/dev/sda2 ...
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2872
Joined: Sun Jan 15, 2012 1:11 pm
by azeam » Fri Jan 04, 2013 1:30 pm
That's true, don't know what I was thinking. I believe though that in Win32Diskimager you can only choose a device from a drop down list and not specify partitions.
User avatar
Posts: 192
Joined: Fri Oct 26, 2012 11:13 pm
by Joe Schmoe » Fri Jan 04, 2013 4:29 pm
azeam wrote:That's true, don't know what I was thinking. I believe though that in Win32Diskimager you can only choose a device from a drop down list and not specify partitions.


Probably true. Which is yet another reason why I would never even consider doing this sort of operation on Windows.
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2872
Joined: Sun Jan 15, 2012 1:11 pm
by rurwin » Fri Jan 04, 2013 5:02 pm
The best part of a million Pi owners are going to disagree with you.

This is yet another reason we need a fork of W32DiskImager or some other tool. A liveCD solution would work if it was customised, but it is far from optimal.

I wonder if some software company would like to sponsor the Raspberry Pi by supplying and maintaining a free SD imaging tool. To do the job properly requires MS support (MSDN subscriptions, Visual Studio etc.) but advertising their company on a million PCs must be worth something.
User avatar
Forum Moderator
Forum Moderator
Posts: 2936
Joined: Mon Jan 09, 2012 3:16 pm
by azeam » Fri Jan 04, 2013 5:38 pm
Not that familiar with Windows software but wouldn't something like Ext2Fsd + dd for Windows work for backing up an ext partition?
User avatar
Posts: 192
Joined: Fri Oct 26, 2012 11:13 pm
by kalehrl » Fri Jan 04, 2013 8:52 pm
Therefore it is not possible to make the image any smaller than the card itself.

It is possible to do just that, reduce the size of the image.
Here the instructions I stumbled upon and they work great:
Backup SD card image to USB device:
Code: Select all
sudo dd if=/dev/sdx | gzip > /some/location/image.gz

To restore the backup:
Code: Select all
sudo gzip -dc /some/location/image.gz | dd of=/dev/sdx

Of course, when restored, the image will be the same size as the original but backup is much smaller.
Posts: 343
Joined: Tue Jul 24, 2012 10:49 am
by pjc123 » Fri Jan 04, 2013 9:01 pm
I have a large backup drive, so I don't worry about the full pi images when using win32diskimager.

However, if space is a concern, another option is to use Clonezilla to just back up the used space on the card. If you are backing up one of the many standard file system (NTFS, ext3, ext4, HFS+, FAT and a dozen or so more) it will just back up the used space on each partition, but worse case if there is an obscure file system, for instance in my case I have a couple of partitions formatted for KVM virtualization, Clonezilla automatically picks dd to back up the entire partition. I use it regularly on the various Linux distros that I have installed on my multiboot PC's (Centos, Ubuntu, Mint, Fedora, etc.) to have one click full system restore disaster recovery images that take up a reasonable amount of space. Full imaging of 650GB drives is obviously prohibitive. I combine my image backup routine with more frequent file backups of critical directories.

I have not tried it on the pi, but there is no reason it should not work; you would run it against the contents of the SD card plugged into a card reader on a X86 computer. Clonezilla runs from a live CD, so there is no activity on the drive/card while imaging it. If I ever get the time, I will give it a try.
Posts: 910
Joined: Thu Mar 29, 2012 3:37 pm
by rpdom » Sat Jan 05, 2013 12:21 am
If all I had to work with was a Windows PC (actually, I don't have one - I'd have to borrow my wife's laptop), I'd download a small Linux Live CD or USB image (something like the Knoppix CD version), boot from that in command line mode and use that to manipulate the SD card or image file using dd, fdisk/cfdisk resize2fs, tar etc.

It would be a bit of a learning experience for those not used to Linux bash command line, but totally worth it and valuable when using the same bash command line on the Pi.
User avatar
Posts: 3965
Joined: Sun May 06, 2012 5:17 am
Location: Essex, UK
by Joe Schmoe » Sat Jan 05, 2013 6:28 am
rpdom wrote:If all I had to work with was a Windows PC (actually, I don't have one - I'd have to borrow my wife's laptop), I'd download a small Linux Live CD or USB image (something like the Knoppix CD version), boot from that in command line mode and use that to manipulate the SD card or image file using dd, fdisk/cfdisk resize2fs, tar etc.

It would be a bit of a learning experience for those not used to Linux bash command line, but totally worth it and valuable when using the same bash command line on the Pi.


Precisely. Very well put.

(I"ve been saying this or similiar message for a long time now, on this board).
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2872
Joined: Sun Jan 15, 2012 1:11 pm