Cloning a hard drive over a network using netcat

My wife's PC has been around for a few years, and I had a newer PC that I wanted to move her onto. Problem was, her old PC only had IDE connectors for the HD, and the replacement only had SATA.

Being a linux guy, I whipped out an old removable USB hd I had lying around, and booted up the replacement PC off of an Ubutnu 9.10 CD I keep around for just such purposes, and i used gparted to clone a copy of the replacement PC's HD off to the USB HD. So the replacement PC is now ready to serve as a true replacement.

On her old PC, I fired up an Ubuntu 10 CD, only because I had a separate Ubuntu 10 CD lying around, and for some strange reason, gparted on the Ubuntu 10 CD bombs. Anyhow this ain't about gparted. So I googled up "copy hard disk over network" and found this: http://www.cyberciti.biz/tips/howto-copy-compressed-drive-image-over-network.html and it did the trick. But here are the specifics I used which actually worked:

Both source (her old PC) and target (the newer pc) are booted up using an Ubuntu 9 or 10 LiveCD. On both PCs I fire up a terminal session

$sudo su -
#passwd root

and I enter a new password for root. I can't tell for sure if you do or don't need to do this. I'm just telling what worked for me. So I now have a root terminal session fired up on both source and target PCs.

Let's say the target PC's IP address is 192.168.0.10. Also, let's say I used gparted on both the source and target to look at the disks, and I determine that /dev/sda is the disk I want to copy on the SOURCE PC, and /dev/sdb is the disk I want to overwrite on the TARGET PC. Very important.

On the TARGET PC, in that terminal session, I issue the following:

#netcat -v -p 2222 -l |bzip2 -d | dd of=/dev/sdb bs=16M

So I see netcat fire up and it says it's listening on port 2222.

On the SOURCE PC, in that terminal session, I issue the following:

#bzip2 -c /dev/sda | nc -v 192.168.0.10 2222

And it looks like this:

root@ubuntu:~# bzip2 -c /dev/sda | nc -v 192.168.0.10 2222
Connection to 192.168.0.10 2222 port [tcp/*] succeeded!

Okay,here is where patience kicked in. I started in 3:00 pm in the afternoon, and it wasn't done until the next morning! Was it the "bs=16M" in the dd command? Both computers were going at gig speed on the NICs. The disk was 80gb, so that'll give you an idea. But you know what? It worked! I rebooted the new PC, and Vista fired up. Awesome.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.3.002. Contact Blog Owner