Linux-based PC Imaging, Part One
Hey, I get paid to be a geek, right?
So, I’ve been having some issues with my network and several Windows XP machines. In a nutshell, these machines seem to lose connectivity after approximately nine hours and fifteen minutes from the last restart. In other words, when my crazy-dedicated engineers work past their ninth hour, their machine slows to a crawl and eventually locks tighter than a Catholic school-girl’s knees. In any case, after weeks of troubleshooting this issue, I’ve come up empty. The best that I’ve got for these guys is either a) Don’t work such long hours or b) Reboot the machine at lunch.
In a further attempt to fully understand what is happening and at what level, I’ve gotten one of these machines and I’m going to install Windows 2000 on it. If we have the same issue, I know it’s hardware. If I don’t, I’ll be certain, within a reasonable percentage of sureity, that the issue is some arcane aspect of Windows XP. Either way, I should be closer to a real answer.
But, before I wipe my current experimental machine, I decided I wanted to back it up. Naturally, I turned to my old friend, Linux. A quick Google turned up a blog entry titled “Cloning XP with Linux and ntfsclone“. So, with a few modifications for my own environment, I followed the instructions there. Incidentally, I used the latest version of Knoppix as a boot CD.
First, open up a terminal/shell session and create a mount point with the following command:
# mkdir /tmp/server
Then, because my DHCP server didn’t give the Knoppix virtual machine the right DNS information, add your server to the /etc/hosts file.
Next, mount the network share that you want to dump the images on.
# mount -t smb -o username=administrator //server1/share /tmp/server
Check how your live CD sees the partitions you want to save with the following command:
# cat /proc/partitions major minor #blocks name 8 0 78150744 sda 8 1 76211608 sda1 240 0 1939136 cloop0
I want to save that 80 GB disk sda, which has a primary partition sda1. First I saved the partition table and the Master Boot Record this way:
# sfdisk -d /dev/sda >/tmp/server/images/cad1r-sfdisk-sda.dump
# dd if=/dev/sda bs=512 count=1 of=/tmp/server/images/cad1-sda.mbr
and then the partitions:
ntfsclone -s -o - /dev/sda1 | gzip | split -b 1000m - /tmp/server/images/cad1-sda1.img.gz_
Note that this saved disk image in 1G files, in case the way I mounted the share to the network server didn’t allow for large files. Sometimes that can get tricky going from Linux to a Windows 2003 server and back, so I decided not to take any chances. It makes a mess of files, but at least it took the guess-work out for me.
Coming soon, the restore process! Keep an eye out!