[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Cloning disks with dd and netcat



Hi

I'm having problems cloning a hard drive. What I want to try do is set
aside a server on our internal network to store a whole bunch of server
images. So instead of manually installing a new server and copying
configs across, we just extract the appropriate image onto a harddrive.

At the moment I've got an image on the image server but when extracting
it to the new disk I am getting an error. I created the image by doing
this:

dd if=/dev/zero of=empty.tmp bs=1024
count=FREEBLOCKSCOUNT
rm empty.tmp

This cleans up the disk space for each partition apparently for better
compression, but I'm not sure about the 2nd line and FREEBLOCKSCOUNT.
After this, which took a while, I issued the following from the image
server which creates the image:

nc -v -w 120 -p 3333 -l < /dev/null > image.gz

Then from the machine we want to clone, I booted with a knoppix cd then
set it up on the network then did this:

dd if=/dev/had bs=512 | gzip -c | nc -v -w 60 <image server ip> 3333

After a few hours, I ended up with image.gz sitting on the image server.

Now, I've got a new 20Gb ready, slotted it into a new PC and booted with
trusty knoppix. I then configured her on the int network with a DHCP
assigned IP address.

I then tried to cat the image from the image server across the network
using netcat like the doc said. This is what I did:

imgserver:/# cat image.gz | nc -v -w 120 -p 3333 -l
listening on [any] 3333 ...

Then I did this on the new pc with knoppix booted:

tty1[/]# nc -v -w 60 XXX.XXX.XXX.XXX 3333 < /dev/null | gzip -dc | dd
of=/dev/hda bs=512 
imgserver.whatever.co.za [XXX.XXX.XXX.XXX] 3333 (?) open

Now it *should* be accepting the image through port 3333 and extracting
it to /dev/had but after a few seconds the error:

connect to [XXX.XXX.XXX.XXX] from fw.whatever.co.za [YYY.YYY.YYY.YYY]
1026
too many output retries : Broken pipe
imgserver:/#

comes up on the image server and then this:

hda: read_intr: status=0x59 { DriveReady SeekComplete DataRequest Error
}
hda: read_intr: error=0x40 { UncorrectableError }, LBAsect=19528,
sector=19528
end_request: I/O error, dev 03:00 (hda), sector 19528
dd: writing `/dev/hda': Input/output error 
19529+0 records in
19528+0 records out
9998336 bytes transferred in 9.226423 seconds (1083663 bytes/sec) 
too many output retries : Broken pipe
root@tty1[/]#

comes up on the new pc. Obviously the first thing I did was swap the
harddrive just in case the one in the new pc is faulty, but I get the
same error. I also tried to use zcat but no luck.

The docs I've been using can be found at http://wyae.de/docs/img_dd.php

Please let me know if I need to supply more info on this or if there is
anything I've left out. Thanks for your time and effort in advance!

Thanks
Dave



Reply to: