PDA

View Full Version : Help to restore a dd image file back to the hard drive



BrianC
10-31-2005, 08:04 PM
I've read the faqs and can find info on creating images but not of restoring them back to the hard drive.

I have created a dd image file of the complete hard drive /dev/hda on a removeable hard drive
using
dd if=/dev/hda of=/mnt/sdb1/image.dd

Now I am trying to restore the image back to the hard drive as an upgrade went wrong.
However
dd if=/mnt/sdb1/image.dd of=/dev/hda is not working.

I think I have to make hda writeable but I don't know the exact syntax of the command I need.
On the left of the desktop I can find icons for hda1, hda3 and hda7 which are currently on my machine but are currently unmounted.
What exactly do I do here?

Hope someone can help.

Regards
Brian C

Dave_Bechtel
10-31-2005, 08:38 PM
Are you getting an error message? Describe "not working."

1. You must be root, and running from the Knoppix CD.

2. NOTHING on hda should be mounted, including swap.
' swapon -s ' == swap status; ' swapoff /dev/hdaX '
' umount /dev/hda* '

3. ' dd if=/mnt/sdb1/image.dd of=/dev/hda bs=2M '

Note: It may be more useful to image partitions (/dev/hda1) rather than the entire drive.

--You can also compress/uncompress the drive image on the fly:
' dd if=/dev/hda bs=1M |gzip -9 >/mnt/sdb1/image.dd.gz '
' gzip -cd image.dd.gz > /dev/hda ' == Restore


I've read the faqs and can find info on creating images but not of restoring them back to the hard drive.

I have created a dd image file of the complete hard drive /dev/hda on a removeable hard drive
using
dd if=/dev/hda of=/mnt/sdb1/image.dd

Now I am trying to restore the image back to the hard drive as an upgrade went wrong.
However
dd if=/mnt/sdb1/image.dd of=/dev/hda is not working.

I think I have to make hda writeable but I don't know the exact syntax of the command I need.
On the left of the desktop I can find icons for hda1, hda3 and hda7 which are currently on my machine but are currently unmounted.
What exactly do I do here?

Hope someone can help.

Regards
Brian C

BrianC
11-01-2005, 03:07 PM
Thanks - it worked perfectly.
Restored the image to the disk and fired up a perfectly working computer again - one for the "True Stories of Knoppix Rescues"

My problem was solved by firstly using a root shell and not getting clever fiddling about with mount, read-write, umount and thereby making the 'device busy' etc.
I particularly like your compression command line - I'll try using it next time.

Many thanks again.

Regards
Brian C

A. Jorge Garcia
11-11-2005, 10:30 PM
I'd like to use your dd procedure to "ghost" a working dual-boot PC to one where I can't resize the XP partition to make room for a KNOPPIX install. I have 5 PCs in this category. I also have 2 PCs that can't read the KNOPPIX liveCD (bad drive - many read errors on CD boot).

So, I'd love to make an image of a working PC with all the partitions intact, however, this is going to be a huge file, right? If I don't compress the file, as described above, how big will the image file be for a 40GB hdd? Will it image all 40GB even if many GBs are not as yet used? If I compress, what compression rate would I get, about 50%? I just don't know where I'd store such a huge image file! If the image file only copies stored files and not physical space, and I compress at 50%, then the image could be as small as 4GB, but I still don't know where I'd store it....

Is there some way to install the image directly as its being made - a straight transfer of data without having to save an intermediary image file at all?

BTW, here's some stats if it helps:
These are Dell GX270s with 40GB hdd, 750MB RAM and Pentium IVs running at 2.8GHz.
Also, the partitions on the working machines are set-up roughly as follows.
hda1: Windows 95 rescue (<1GB)
hda2: Windows XP primary boot partition (19GB)
hda3: KNOPPIX-installered Linnux ext3 partition (19GB)
hda4: linux-swap (whatever's left < 1GB)

TIA,
AJG

Markus
11-11-2005, 11:33 PM
Perhaps try dd and netcat booting knoppix from the cd with noswap cheat on the master.

- Check the ip of the slave.
- Start netcat on the slave: nc -l -p 8000 | dd of=/dev/hda
- Then start pushing data from the master you wish to copy: dd if=/dev/hda | nc 192.168.x.yyy 8000
- Go get a laaaaarge cup of coffee.

I would set aside a router disconnected from internet for this just to make sure nothing gets in the middle.
You can choose the port, I chose 8000 just to put something there.

Here's a boot floppy (2) with dd and nc for the boxes that won't boot from cd http://omnibus.uni-freiburg.de/~giannone/rescue/current/

Disclaimer: haven't tried this ;)

PS: Wouldn't it just be easier to pull the hd's and dd locally on one computer?

OErjan
11-12-2005, 06:43 PM
yes the image will be as large as the hdd, compression depoends on content... but 50% is not unheard of.

hmm, you could perhaps use cp for the linux part (perhaps pipe it through compression as above), and dd only for the bootable win part, sadly I do not know if things work without dd on the bootable WIN partition though (doubt it).
this is because WIN has some files that must be in certain points on the hdd and such. and as dd would copy everything even bad blocks... it should work great for that.
in Linux I would only use dd for the mbr (to getlilo...) then I should be able to just copy things across.
cp -avx /mnt/cd-dvd-with_linux_stuff/ /mnt/hdXYlinuxpartition/
Atleast the linux parts WILL work (IF hardware is similar enough).
I use this as backup for my linux systems.

JSMATT
12-04-2005, 05:07 AM
I've read the faqs and can find info on creating images but not of restoring them back to the hard drive.

I have created a dd image file of the complete hard drive /dev/hda on a removeable hard drive
using
dd if=/dev/hda of=/mnt/sdb1/image.dd

Now I am trying to restore the image back to the hard drive as an upgrade went wrong.
However
dd if=/mnt/sdb1/image.dd of=/dev/hda is not working.

I think I have to make hda writeable but I don't know the exact syntax of the command I need.
On the left of the desktop I can find icons for hda1, hda3 and hda7 which are currently on my machine but are currently unmounted.
What exactly do I do here?

Hope someone can help.

Regards
Brian C

I am having a similar challenge. I made a HD image using DD, but grabbed the SDA1, not the entire disk image SDA. Every attempt I make to restore the image, including ones involving restoring to a partition larger than the original disk etc., all result in failure. The image I am trying to restore is an XP drive and the MFT does not restore to the correct location, if at all. Is there something simple I am missing to enable a simple recovery of this image? I've restored dd'd images, but am at a loss to restore a partition.

Any help would be most apprec.; I've spent way too many hours trying various alts. unsuccessfully....

Dave_Bechtel
12-04-2005, 08:30 AM
Same thing happened to me on a laptop. I was screwed, and had to basically reinstall Windows - so at that point I said hell with it and installed Knoppix. :)
One can always run Windows under vmware, after all...



I've read the faqs and can find info on creating images but not of restoring them back to the hard drive.

I have created a dd image file of the complete hard drive /dev/hda on a removeable hard drive
using
dd if=/dev/hda of=/mnt/sdb1/image.dd

Now I am trying to restore the image back to the hard drive as an upgrade went wrong.
However
dd if=/mnt/sdb1/image.dd of=/dev/hda is not working.

I think I have to make hda writeable but I don't know the exact syntax of the command I need.
On the left of the desktop I can find icons for hda1, hda3 and hda7 which are currently on my machine but are currently unmounted.
What exactly do I do here?

Hope someone can help.

Regards
Brian C

I am having a similar challenge. I made a HD image using DD, but grabbed the SDA1, not the entire disk image SDA. Every attempt I make to restore the image, including ones involving restoring to a partition larger than the original disk etc., all result in failure. The image I am trying to restore is an XP drive and the MFT does not restore to the correct location, if at all. Is there something simple I am missing to enable a simple recovery of this image? I've restored dd'd images, but am at a loss to restore a partition.

Any help would be most apprec.; I've spent way too many hours trying various alts. unsuccessfully....

JSMATT
12-05-2005, 05:22 PM
In my efforts to restore the partition, I tried to restore a zero'ed drive in two steps. My resto was based on a functioning disk. I restored the first 16,127 sectors then I tried to restore the partition I am trying to recover at 16,128 (this disk structure matches the MBR in sector 0, the Dos LBA at 16,065, and the NTFS partition at 16,128).

The headache is that dd will not restore to the 16,128 and beyond sectors once I've restored the first 16127 sectors. Here's the command I used:
dd if=/mnt/sdd1/serverorig.img of=/dev/sdc obs=512 seek=16128

I even tried changing the sdc to sdc1 thinking the first 16127 sectors is now seen by Linux as a DOS Lba partition. Either way, the .img file doesn't restore.

Any thoughts?

OErjan
12-05-2005, 05:49 PM
hmm, make the poatrition and then copy the files there from the image, just mount the image "-o loop"

mount -t filesystem -o loop /path/to/file.img /mount/point wont work on ntfs but...

ugopher
12-12-2005, 08:32 PM
I have followed this topic and I was wondering the following: If I already have a dd image split into 640M chunks and want to restore the image onto a new destination drive, 1) Do I need to format my new destination disk as NTFS before I reasseble the image onto my destination drive? 2)Also, Is there an additional command that must be used to tell Knoppix to reassemble the chucks of dd.img.000, dd.img.001..... while it is writing to the destination disk? :?

OErjan
12-13-2005, 08:28 PM
no formating needed, you can use the comand cat to put the pieces together again.
like this lets say you have the files::: file1.img file2.img...file9.img you can merge them with the comand
cat file?.img >>whole.img this will take them in order from 1-->9 and put then as one, but as you have them on different CDS we must go a different route.
so let us say you have image1 on a mounted CD and want it on /dev/hda you do
cat /mnt/cdrom/image1.img>>/dev/hda next you unmount the cd and put cd 2 in
cat /mnt/cdrom/image2.img>>/dev/hda ... ... ...
cat /mnt/cdrom/image9.img>>/dev/hda
the >> tells cat to continue with the new stuff just where the old ended.
let us hope it works, sometimes it may error out. if so ask and i will try to fins another way, yes there are other ways, SEVERAL other ways.