I’ve ran into some weird instance of this old RedHat Linux machine that is starting to die.. The old 30GB disk is clicking rather loudly…!
To make matters worse, the computer is not only in another country but on another continent. And no the users won’t let me take it down, ship it or let local techs work on it, they want it virtualized, and they want it to be done without taking it down…
All I have to work with is an old Windows 2003 server with a big external USB disk, and I don’t even have administrator privileges on the 2003 server so I can’t install anything ‘fun’ like VMWare, VirtualPC, VirtualBOX or anything else.
So I thought I’d go old school with this and use netcat.
Thankfully there is a win32 version of netcat, and the Linux PC already had it installed. So it really was trivial I must say knowing what to do once all the bits are in place. From the Windows machine I just ran:
nc -p 2222 -l |gzip -dc > disk0.raw
And on the Linux PC I ran:
cat /dev/hda | gzip -c | netcat 10.0.1.10 2222
So on the Windows side, netcat will listen on TCP port 2222 and then decompress the stream with gzip and save that into the file disk0.raw. On the Linux side, it’ll read the harddisk, compress the data with gzip and then using netcat redirect the stream to the Windows host.
It took about 30 minutes, I suppose if the disk wasn’t in a questionable state I’d have cleared out the empty space to speed it along, however I felt that doing a large amount of writing to a questionable disk is just asking for trouble.
Once the transfer was complete I was able to then fire up Qemu 0.15.0, and have it mount the raw disk image, and it worked perfectly! I added the modules for the AMDPCNet card (pcnet32) and I was able to use the user mode NAT via Qemu, and redirect a local TCP port into the VM’s sshd …. Something like this:
qemu -L pc-bios -m 256 -net nic,model=pcnet -net user -hda disk0.raw -no-reboot -redir tcp:3333::22
And that was that. Now we have a perfect copy of the machine!