NOTE: Much of what I describe below can now be accomplished with the free VMware Converter. If you're migrating a Windows-based system, I recommend using that. If you'r running another operating system, this is probably still applicable.
DISCLAIMER: This tutorial involves messing with disks at a low level – a single typo on your part (or mine) in many of the commands could toast your data. Do not proceed unless you understand what each command does and have the common sense to verify it before running it. I take no responsibility for destroying your machine. In many commands, I reference /dev/hda as the disk to image and /dev/hda1 as the partition - these are placeholders, you must replace them if you are not imaging an IDE disk or the partition is not the first.
While imaging my XP system before reformatting recently, I realized that it would be nice to have a copy of my current environment available when I was rebuilding the system. Documents, images, files, etc would all be preserved in an image, but the settings and configuration options for many programs are stored in the registry or in proprietary configuration files that can't easily be accessed from a simple disk image. I decided to figure out how to boot my system as a VMWare virtual machine. The following is a general tutorial – moderate competence with Linux is assumed.
Before you start, be aware you’ll need a fileserver with at least as much disk space as your image. You’ll also need a licensed copy of VMware (or the VMware player) and a system to run it on (probably just the same fileserver the image lives on).
If you’ll be imaging from a SCSI disk or an IDE disk attached to an onboard RAID header or third-party PCI controller card (including anything from Promise, Highpoint, or the controllers that come with recent drives), it’s probably a good idea to install the virtual BusLogic adapter driver from VMWare’s site before imaging - it should save you from a repair install later.
The first thing you’ll need to decide is whether you’ll be imaging the entire drive or a single partition. Imaging the entire drive will make things simpler, but often the entire drive is too large to image and store. In my case, I had a 160GB drive, or which only 60GB was used, so I chose to shrink and image the partition.
Imaging a single partition
If you don’t have room to image a mostly empty drive, this is the best option. Using a partition utility, shrink the partition to reduce the amount of free space. I used PartitionMagic, although booting off the SystemRescueCD and using QtParted will probably work just as well. Write down all partition details, include start/end sectors, the total sectors for each partition, and the total sectors for the disk.
Now, you’ll need to image the MBR and the partition itself. I’ll leave the details to you, but here’s how I did it:
Boot off the SystemRescueCD, Knoppix, or into rescue mode off a recent RedHat CD
Bring up a network interface so you can communicate with your fileserver. Image the boot record and pipe to netcat using:
dd if=/dev/hda bs=512 count=63 |
nc <fileserver ip> <port>
NOTE: If you are
running the netcat listeners under Cygwin, you will need to
pipe the output through cat, eg:
nc -l -p <port> -w 3 | cat
-B > image.dd
Set up a netcat listener on your fileserver (make sure
iptables isn’t blocking it):
nc –l –p <port> –w 3 >
server.mbr
Now, image the partition:
dd if=/dev/hda1 | nc
<fileserver ip> <port>
and setup a netcast listener on the fileserver:
nc –l –p <port> –w 3 >
server.dd
Imaging an entire
drive
This method is slightly easier than a partition image. I’ll
leave the details to you, but here’s how I'd do it:
Boot off the SystemRescueCD or into rescue mode off a
recent RedHat CD
Bring up a network interface so you can communicate with
your fileserver. Image the drive using dd and pipe to
netcat using:
dd if=/dev/hda | nc
<fileserver ip> <port>
Set up a netcat listener on your fileserver (make sure
iptables isn’t blocking it):
nc –l –p <port> –w 3 >
server.dd
Setting up the VMWare
VM
Run through the VM creation wizard and set options as you'd
like. We’ll be tweaking all the disk-related options at the
command-line, so don’t worry about that now.
Building a
raw disk from a partition image
Copy the MBR and partition images into the directory of the
VM you created. In that directory, you’ll find a file named
<VM>.vmdk and <VM>.vmx. Edit the .vmdk file to
look like this:
# Disk
DescriptorFile
version=1
CID=fffffffe
parentCID=ffffffff
createType="monolithicFlat"
# Extent description
RW 63 FLAT "server.mbr" 0
RW <partition sectors> FLAT "server.dd” 0
RW <unallocated sectors> ZERO
# The Disk Data Base
#DDB
ddb.virtualHWVersion = "3"
ddb.geometry.cylinders = "<cylinders>"
ddb.geometry.heads = "<heads>"
ddb.geometry.sectors = "<sectors>"
ddb.adapterType = "ide" or "buslogic"
The above deserves some explanation. In the extent
description section, you have three definitions. The first
is the MBR and is pretty self explanatory. The second is
the partition itself – this one you’ll have to plug in the
total sector size of the partition (not disk) that you
wrote down from the partitioning utility. The third entry
is the remainder of the disk – this should be the number of
unallocated sectors. If that number wasn’t given in the
partitioning utility, it should be <disk sectors> -
<partition sectors> - 63. The DDB section will vary
depending on the disk type or what controller it was
connected to. If you imaged from an IDE drive connected to
a standard IDE header on the motherboard, you should be OK
setting cylinders = <partition sectors> / 16 / 63,
heads = 16, sectors = 63, and adapterType = “ide”. If you
imaged from a SCSI disk or an IDE disk attached to an
onboard RAID header or third-party PCI controller card
(anything from Promise, Highpoint, or the controllers that
come with recent drives), you should you the following
settings: cylinders = <partition sectors> / 16 / 63,
heads = 255, sectors = 63, and adapterType = “ide”.
Additionally, you’ll have to edit the .vmx file and change
all “ide0:0” references to “scsi0:0”, all “ide0:1”
references to “ide0:0”, and add the line:
scsi0.present = "TRUE"
Building a raw disk from a disk
image
Copy the disk image into the directory of the VM you
created. In that directory, you’ll find a file named
<VM>.vmdk and <VM>.vmx. Edit the .vmdk file to
look like this:
# Disk
DescriptorFile
version=1
CID=fffffffe
parentCID=ffffffff
createType="monolithicFlat"
# Extent description
RW <total sectors> FLAT "server.dd” 0
# The Disk Data Base
#DDB
ddb.virtualHWVersion = "3"
ddb.geometry.cylinders = "<cylinders>"
ddb.geometry.heads = "<heads>"
ddb.geometry.sectors = "<sectors>"
ddb.adapterType = "ide" or "buslogic"
In the extent description section, you’ll have to plug in
the total sector size of the disk that you wrote down from
the partitioning utility. If you didn’t write it down, it
should be <image file size / 512>.
The DDB section will vary depending on the disk type or
what controller it was connected to. If you imaged from an
IDE drive connected to a standard IDE header on the
motherboard, you should be OK setting cylinders =
<partition sectors> / 16 / 63, heads = 16, sectors =
63, and adapterType = “ide”. If you imaged from a SCSI disk
or an IDE disk attached to an onboard RAID header or
third-party PCI controller card (anything from Promise,
Highpoint, or the controllers that come with recent
drives), you should you the following settings: cylinders =
<partition sectors> / 16 / 63, heads = 255, sectors =
63, and adapterType = “ide”. Additionally, you’ll have to
edit the .vmx file and change all “ide0:0” references to
“scsi0:0”, all “ide0:1” references to “ide0:0”, and add the
line:
scsi0.present =
"TRUE"
Booting the
VM
Now that the disk is configured, you should be able to boot
the VM. If you get an “unmountable boot device” blue
screen, you probably have chosen the wrong adapterType or
did not install the virtual BusLogic driver mentioned at
the beginning of the doc. If you think you just forgot the
driver, then you’ll need to boot the VM off your XP CD and
repair the install using a driver disk with buslogic driver
on it.
Also be aware that since Windows activation is tied to the
hardware that it’ll probably reset to an unactivated mode.
You’ll have a 30 day window to activate, which should give
you enough time to migrate all the data you need. To clean
things up a bit, you’ll also probably want to install the
VMWare tools and remove any drivers for peripherals that
are no longer attached.
Accessing
the VM
I found it was easiest to configure bridged networking for
the VM and to enable Windows Terminal Services to allow
remote access to the new VM. Once my system was rebuilt and
on the wire, I could simply remote desktop into its former
self to copy files, examine configuration settings,
etc.
