Guide: How to migrate active Windows XP to VirtualBox

This is for discussing general topics about how to use VirtualBox.
droopy
Posts: 5
Joined: 22. Sep 2009, 13:58
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Windows XP, Ubuntu, FreeNAS

Guide: How to migrate active Windows XP to VirtualBox

Post by droopy »

How to migrate active running Windows XP to VirtualBox without any reboot of host system

Hi, I want to share with you my struggle with migrating to VirtualBox. I hope it helps someone.

Windows installations are "not happy" when we try to move them from one partition to another. The complete computer change can be a lot more tricky. But it is feasible and I found one just enough easy way to do it that I could remember and then write about.

First, I tried it hard by this guide and failed miserably with 6 hours of wasted time and 3x 100GB of wasted diskspace (using Live CD of Ubuntu and dd-ing 100GB partition). Then I used my usual tool for backup - the great and only Snapshot.exe and the process got a lot more easier.

This guide describes how to move existing active Windows XP to a VirtualBox Machine inside of this active Windows XP, doing so while running the host (to be virtualized) system and without any help from another OS. We will accomplish this just by using second partition or disk with enough free diskspace. We will need roughly 2x the diskspace currently occupied by Windows XP on system drive.

Example of system

- Disk C:\ has a size of 100GB and contains Windows XP system and all system files. It is currently using 30GB and 70GB is free.
- Disk D:\ has a size of 250GB. It is using 180GB and 70GB is free.
We will need around 60GB to execute migration (at least 30GB on Disk D:\ for partition backup) and after successful migration the final footprint will be around 30GB for VDI drive.

What we need
  • ISO image or CD with Windows XP Installation (I used Windows XP SP3)
  • Installed and running latest release of VirtualBox (I used version 3.0.6)
  • One running virtualized Windows XP inside of the VirtualBox with working Bridged network and enabled File Sharing (the size of my clean Windows XP installation was just about 1.5GB)
  • CPU with enabled virtualisation extensions (I used AMD Athlon 4850e)
  • Software for drive backup and restore - Drive Snapshot
How To Steps

1. Prepare the system

First create clean Virtualized Windows XP environment (if you do not have it prepared already) by creating new Virtual Machine with 256MB RAM, 10GB disk, serving the Windows ISO image to the machine and install windows as usual.

Enable File Sharing on both host and guest systems. Setup VirtualBox network for our Windows XP machine to Bridged network and let the router and DHCP assign an IP address. If you don't have router on your network, use another network type (NAT, ...) or assign IP manually. The goal here is to be able to share files between host and guest systems, so if you can share and copy files between them, it is enough.

2. Prepare host to migration

Use MergeIDE utility or use regedit to manually delete entries from "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices". I deleted only the entry for C drive, but even this is maybe unnecessary.

Close all running applications. This step is not necessary because Drive Snapshot can backup the system drive while you work on it without any problems. But you maybe want your work to be saved on guest system.

3. Backup host system drive

Use Drive Snapshot to create backup of system drive onto the second drive - example: D:\WinXPBackup\drive.sna. Enable sharing of this directory (in our case D:\WinXPBackup).

4. Restore the system drive inside the guest machine

Edit preferences for guest Windows XP machine - add new drive with the same size as the backed partition from step 3. It should create small VDI file for empty virtual disk. Run the clean guest Windows XP. In the guest OS, right-click on This Computer, click on Manage, then in Computer Management choose Storage/Disk Management. Format the new drive, activate it. Wait while format is done. Run Drive Snapshot and restore the backup from step 3 onto the new disk. Point to the shared directory from the host system. This should take a while because the whole backup is (in case of using Bridged Network) copied trought the LAN interface from host to guest. After restore is done, the newly created VDI file is now full of data - another 30GB used. The *.sna backup from Drive Snapshot can be now deleted and I recommend stopping the guest OS and create backup of our VDI file to another location.

5. Creating new guest OS and repairing installation

Now we have VDI file with complete backup of our Windows XP. But it will not work right away, because we changed the hardware almost completely. But first, let's create new Windows XP machine. Select our VDI file as it's only disk. After creation, go to preferences and in system check Enable IO APIC - it has to be enabled to ensure that our virtual system still keeps the same HAL as when installed.

Now to the repair. Let's run the machine.

If you did all OK, it should boot to Windows with no trouble, but that was hardly my case.. When I first booted, I had a little fun first as the boot loader of Windows 7 let me choose to select what to boot (I had Windows 7 installed on different disk when I created the image of my host system). After I chose to boot "previous version" it stopped right at blank screen and freezed :)

6. So, let's troubleshoot...

I tried to boot from ISO image and repair bootloader in Recovery Console, but Windows Installation didn't recognize any Windows on the disk and thus did not let me choose recovery console.

The second try learned here was succesfull: I ran again the machine with clean Windows XP, logged to Windows and from the Windows ISO image installed the Recovery Console to bootmenu by command: "d:\i386\winnt32.exe /cmdcons". Then rebooted the guest, went to the Recovery Console, selected the "E:\WINDOWS" (our VDI file) from menu of availaible systems and run "fixmbr" and "fixboot e:".

Finally I checked the Enable IO APIC box in System/Motherboard and also Turn on PAE/NX in System/Processor - Extended Featues (don't know if it helps) in preferences of our XP machine and started it. It halted again, but on next restart I had a choice to go to Safe Mode and it worked. Another restart and I was in working environment. The final steps was to install VirtualBox drivers extensions and enable Direct 3D support (enabling in machine preferences and installing extensions drivers again in Safe Mode).

And there you go, finally.. "Yo Dawg, I herd you like Windows XP, so we put yo Windows XP in yo Windows XP, so you can virtualize while you virtualize" (not really possible) :)
delaunay
Posts: 2
Joined: 24. Sep 2009, 10:52
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: windows xp

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by delaunay »

Hi,
I'm trying the same thing !
But unfortunately, my VM doesn't start.
Y take a VirtuelBox critical error during starting, just after Safe Mode.
droopy
Posts: 5
Joined: 22. Sep 2009, 13:58
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Windows XP, Ubuntu, FreeNAS

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by droopy »

Hi,
do you mean that VirtualBox crashes? Can you boot to Safe Mode or it crashes before? Did you fixed bootloader with fixmbr and fixboot commands?

I would try playing with VirtualBox setup. Or you can disable hardware in registry offline from the clean Windows installation. http://scottcross.blogspot.com/2006/03/ ... fline.html
delaunay
Posts: 2
Joined: 24. Sep 2009, 10:52
Primary OS: MS Windows XP
VBox Version: OSE other
Guest OSses: windows xp

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by delaunay »

Hi,

I just resolved via Upgrading.

I didn't needed to make more large partitions. ( I used DriveImage XML)
I just had to activate ACPI and IO ACPI.


Thanks four your Guide.
NeBlackCat
Posts: 154
Joined: 3. Aug 2008, 13:37

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by NeBlackCat »

Do you mean that you are converting an XP installation to a VM, to run inside the original XP installation?

If so, aren't you going to run into issues with identical SIDs?
NeBlackCat
Posts: 154
Joined: 3. Aug 2008, 13:37

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by NeBlackCat »

I was also wondering why this approach was taken as it seems a bit long winded compared to what I usually do, which is (as far as I remember):

1) Create a new hardware profile, set it to default, disable all vbox/vm-unfriendly drivers/services in it (also see hints in the Sun page you referred to)

2) Install VMware Converter, run it to image the live partition to a VMDK

3) Mount the VMDK as a drive letter and replace HAL (as necessary), then unmount.

4) Create new VM, add the VMDK to it, start it, and you're good to go.

If you really wanted a VDI instead of a VMDK (though I don't think there's any reason these days as VBox's VMDK support has caught up with its native VDI container's capabilities) then there'd be an extra conversion step using the vbox tools.

I still think there should be a tool for this.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by Perryg »

I might pipe in on the reason to convert to VDI over VMDK.
I tested this and after converting to a VDI the VM was noticeably faster in VirtualBox.
If I had to put a number to it I would say around 20% - 30% faster. But that was just on one machine and one machine file. Your mileage may vary.
NeBlackCat
Posts: 154
Joined: 3. Aug 2008, 13:37

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by NeBlackCat »

Very interesting! What type were they (fixed/expanding, normal/write through, snapshots)? Did you convert in any way that might have de-fragged the contents (eg. contents copy)?

If this is generally true then it needs to be stated in big flashing letters in the manual.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by Perryg »

Don't know for sure I did a cloneVDI and saved it. All VMs I have are dynamic expanding, normal, I do not use snapshots.
As I said this was one file and one PC. I really don't see a need to specify the speed in the manual. It is what it is.
Although if you read the manual you will see that VMDK is still experimental, so maybe that has something to do with it.
NeBlackCat
Posts: 154
Joined: 3. Aug 2008, 13:37

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by NeBlackCat »

Well the latest manual I have explicitly states that all features are supported on both VMDK and VDI, and gives the impression that they're on equal par as vbox containers. That made me choose VMDKs for everything, as they're more supported by other tools too. However I'd have stuck with VDIs if I'd known they were 3/4 speed, so I do feel that, if it is indeed the case, it needs to be clearly stated so that others don't make that mistake.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by Perryg »

Fully supported means that it will work. VBox also supports ext3 and ext4 one is faster and one is slower.
I have not seen anywhere that it states that just because it is supported that you should use it because it is faster.
In my opinion it is not. Check it out yourself. I said it may vary. Kind of like Linux and Windows.
They are both supported but Linux for the most part is faster.
droopy
Posts: 5
Joined: 22. Sep 2009, 13:58
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Windows XP, Ubuntu, FreeNAS

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by droopy »

NeBlackCat wrote:I was also wondering why this approach was taken as it seems a bit long winded compared to what I usually do, which is (as far as I remember): ...
Hi, It seems long because it was my own attempt to do it. I didn't find any better guide, so I had to create my own. I don't know about the VMware disk converter/copy tools, but I had 100GB system partition and I presume it would need another 100GB just to convert it into VMDK image. My solution uses just 30GB (used disk space in Win XP system disk).

Btw, how do you create new Hardware profile and how do you change/replace HAL on mounted drive? And can I convert the VMDK to VDI with dynamic size allocation?
NeBlackCat
Posts: 154
Joined: 3. Aug 2008, 13:37

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by NeBlackCat »

Perryg wrote:Fully supported means that it will work. VBox also supports ext3 and ext4 one is faster and one is slower.
I have not seen anywhere that it states that just because it is supported that you should use it because it is faster.
In my opinion it is not. Check it out yourself. I said it may vary. Kind of like Linux and Windows.
They are both supported but Linux for the most part is faster.
VBox doesn't support ext3 or ext4, it supports container files into which the target OS can put it's own filesystems (like ext3 or ext4), and of course it can itself be physically installed on ext3 or ext4 partitions on the host. None of these things require explicit vbox support. Hence it is nothing to do with vbox wether one particular target OS file system is faster or slower than another, and not vbox's responsibility to document any major differences.

Container files (vmdk/vdi) are however explicitly implemented/supported by vbox, and if it's implementation of one is *substantially* slower than another, as has been suggested, then (imho) it should be stated somewhere so that the user can make an informed choice of what to use.

The manual does, for example, tell you that the SATA virtual hard disk adapter is faster than the IDE one, and will likely get faster in the future, so it's already established the precedent and you can use that information to choose which to use in your VMs.

TBH I can't really believe that anyone would seriously think that users are not interested in knowing that, if they pick VMDKs, then they're going to get 30% less performance than if they picked VDIs.
Last edited by NeBlackCat on 10. Oct 2009, 10:44, edited 2 times in total.
NeBlackCat
Posts: 154
Joined: 3. Aug 2008, 13:37

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by NeBlackCat »

droopy wrote:Hi, It seems long because it was my own attempt to do it. I didn't find any better guide, so I had to create my own.
Sure, we've all been there! :-)
droopy wrote:I don't know about the VMware disk converter/copy tools, but I had 100GB system partition and I presume it would need another 100GB just to convert it into VMDK image.
VMWare converter is explained here. The gist is that it's a free utility which you install on the physical (Windows) system you're going to virtualise, and it creates a vmware virtual machine for you (from inside your physical system while it's still running) which includes a VMDK image of the hard disk. It also does some other things, if you tell it to, like substituting real drivers for virtual ones, and adding the virtual tools. This is obviously for VMWare virtual machines (not VirtualBox), but the imaging of the physical disk to VMDKs is useful to VirtualBox users too (if you choose to use that format).

There's also a commercial version which is a boot CD, ie. you boot your physical system from the CD and make a virtual machine from it. It can also do other machines on the network. That avoids having to install anything on your physical system, or risk snapshotting/imaging the hard drive when application files are in an inconsistent state (as they might be when the system is actually running).

Coincidentally, I just found a nice looking tool called MOA which produces a Bart-type boot CD which can cold-convert/image your system/hard drive using just the free VMWare converter. I'm about to play with that, and will get back.

Having a similar tool to VMWare Converter, doing the same things, for VirtualBox would be tremendously useful, but it's apparently not something on Sun's radar. I've suggested before that a bounty for someone in the community to do it might be a good idea.
droopy wrote:My solution uses just 30GB (used disk space in Win XP system disk).
Unless I misunderstood something (quite possible!) it needs 60GB (30GB drive temporary snapshot plus 30GB final VDI) plus a temporary Windows installation while actually working, plus double copies (one direct, one networked). Not saying that's better or worse, it's just that I wanted a way which just created my virtual disk (from my physical one) fully populated in one click with no unnecessary steps or copies, and ideally without having to install anything.
droopy wrote:And can I convert the VMDK to VDI with dynamic size allocation?
I think/hope so, but I'll check that as I explore MOA. Until I just read the revelation about vbox's slow VMDK support (not checked yet) I was planning to use VMDKs exclusively, so I havent looked at VDIs much.
droopy wrote:Btw, how do you create new Hardware profile
Go into the "System" control panel applet and activate the "Hardware" tab and the "Hardware Profile" button. There you can create profiles, which are given to you in a menu when Windows boots. For any driver or service (but unfortunately not application) you can choose which profiles it should be allowed to run in. I create a default profile which is just the same as my normal system, then one called "vbox" which doesn't run anything not relevant to (or dangerous for) running in a virtual machine. For example, my nvidia display driver is disabled in "vbox" profile.
droopy wrote:how do you change/replace HAL on mounted drive?
See here. It's just a DLL in the SYSTEM32 folder, but the trick is knowing which one to use, depending on whether your VM will use ACPI/AHCI/multiple CPUs. They're all on the XP distro cd.
droopy
Posts: 5
Joined: 22. Sep 2009, 13:58
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Windows XP, Ubuntu, FreeNAS

Re: Guide: How to migrate active Windows XP to VirtualBox

Post by droopy »

NeBlackCat wrote:
droopy wrote:My solution uses just 30GB (used disk space in Win XP system disk).
Unless I misunderstood something (quite possible!) it needs 60GB (30GB drive temporary snapshot plus 30GB final VDI) plus a temporary Windows installation while actually working, plus double copies (one direct, one networked). Not saying that's better or worse, it's just that I wanted a way which just created my virtual disk (from my physical one) fully populated in one click with no unnecessary steps or copies, and ideally without having to install anything.
I will just try to explain the disk usage. The 30GB I wrote was the space needed on another partition/disk - for backup of system partition. The other space 30GB for restoring backup on virtual disk and also the clean Windows installation (1.5GB) could be placed on the system partition (if there is enough free space). There is no need for other space (unless backup is needed) because when creating virtual disk with dynamic size allocation - it has small size, maybe 1 MB and it grows while the image is restored into it - so the peak space needed is 2x30GB+1.5GB of which only 30GB needs to be on another partition/disk.

Thanks for answers. VMDKs tools looks really helpfull. Keep on the investigation :)
Post Reply