Linux-based PC Imaging, Part Two
This time, we’ll restore the image we made last time
mkdir /tmp/server mount -t smbfs -o username=my_user_name //server_name/share /tmp/server
Now, this assumes that you don’t have anything installed on the new pc yet and are working with just a blank, unformatted hard drive. First, I restored the partition table and the master boot record:
# sfdisk /dev/sda < /tmp/server/images/cad1r-sfdisk-sda.dump
# dd if=/tmp/server/images/cad1-sda.mbr of=/dev/sda
And then the partitions. Since I had several files produced by split for my primary partition, I needed to take them all, in the right order of course. Now, keep in mind that when we used split in the last post, it added “aa”, “ab”, “ac”, etc. to the end of the file name.
# ls -l /tmp/server
will help you check which files you need for the next step.
Now, again, this all assumes that you had a single partition on the original machine and are restoring a single partition. First, change to the directory where the images are:
cd /tmp/server
Now, we restore the image files with the command below. You’ll have to “cat” all the files in the image directory on the server. Notice the pattern of the file names? That’s what split did for us. Now, rather than do the work manually to restore them, I used a little bit of shell code and a variable reference to save you the need to type the names of all the files. Also, the little “-” at the end of the line does matter, so don’t forget it. Oh, and this command should all be on one line.
cat cad1-sda1.img.gz_a[a-z] | gunzip -c | ntfsclone --restore-image --overwrite /dev/sda1 -
Reboot into your new Windows XP clone.
It’s just like magic, isn’t it?