Pages

P2V: How to 'virtualise' your old PC

Why am I Virtualising a PC?
I've recently upgraded my wife's old computer to give her a faster, cleaner PC running Windows 7 rather than the older Windows XP. The PC she is moving from is a slow, single-core Athlon PC with only 1G RAM. In today's world it is now too noisy and too slow to cope with modern software and security demands.

Normally, I would just run the File Transfer Wizard on her old PC and on her new one and that would be it; however there is one old application my wife uses regularly that may not run under Windows 7 so I must make sure that this application is available to her on the new PC.

As her new PC is so much more powerful than her old one, there is enough spare computing power to run her old PC within her new PC using a process called virtualisation. This means she can enjoy all the benefits of Windows 7 yet still be able to run a virtual version of her old PC as and when she needs this old application.

Before we go through the steps involved in creating a virtual PC, let's look briefly at the technology of Virtualisation and what's involved:

What is Virtualisation?
Virtualisation is the technology that allows you to simultaneously run a number of independent and fully-functional computers called Guests and their applications on a smaller number of more powerful physical machines called Hosts.

This ability of running virtual computers is very popular in the IT community as a way of making the most of increasingly scarce and costly IT resources. In commercial IT environments these Hosts are typically very powerful servers. They run sophisticated and often expensive software that provides security, support and control for large numbers of virtual computers - typically as part of Enterprise Computing.

Even in domestic environments, today's newer desktop and laptop computers have more than enough spare capacity so that you can also run Virtual PC's - perhaps to try out a new configuration or operating system or to maintain an old PC or server that is still essential but now too old to be reliable.  This is known as Desktop Virtualisation and is usually freely available to use.  The catch is, however, that often there is little or no support available so you need to do a lot of research to make any progress.  This is why I've written this article to pass on my findings in the hope that it is useful to you in your research.

There are a number of Desktop Virtualisation software packages that are freely available for home users so there's no reason why you can't jump in and play with your own virtual environment.  Three examples are:

There are plenty of articles and guides around that will help you install the Host software on your PC so I won't cover that here. Instead, I'm going to walk you through the virtualisation of my wife's Windows XP PC and then show you how to get this running as a Guest on a newer Host computer.  I chose Oracle's VirtualBox as the Host package as it seems the simplest to use.

The process of converting an existing real PC into a virtual PC is known as Physical to Virtual conversion and is usually referred to as a P2V.  I am therefore about to carry out a P2V of her old PC and then install this as a Guest using her new PC as the Host.  She will then have all the new software she needs and will also have full access to her old PC configuration (and that application) but, crucially, I can now turn off her old PC so she does not have to worry about running two PCs in her office.

The Virtualisation process
The basic steps needed to create a Virtual PC in VirtualBox are simple and straightforward. You open the VirtualBox Manager, click on 'New', step through the New Virtual Machine Wizard and what is created is a skeleton of a PC just the same as if you'd built the PC out of hardware. Normally, you'd then install an OS, load up your applications and away you go. However, as I am actually virtualising a real PC, I have to follow a different path, as I actually have a working computer from which to start.

Logically then I would expect to:
  1. Make a disk image copy of the hard disk(s) in the working PC I am virtualising
  2. Put the disk image copy onto the new PC
  3. Build a matching Client in the VirtualBox Manager on the Host PC
  4. Mount the disk image copy as the system disk in the VirtualBox Client
  5. Launch the Virtual PC with the disk image copy

And you'd think that was all. Just carry out these steps and you'd then be running a virtual version of your old PC....

Well, it would be all, if Windows wasn't so fussy about how it is installed. Windows memorises which disk controller it was installed on and fails to boot if this controller changes. Since we are moving from a Real PC with a Real disk controller to a Virtual PC with an emulated controller, the odds are that by just carrying out the steps above we will end up with a system that doesn't boot as it is highly unlikely that the disk controllers will match.. There may be other incompatibilities too, with Graphics card drivers and so on.

The VirtualBox step-by-step guide
Luckily, help is at hand. Those nice people on VirtualBox have a little article that explains how to go through the virtualising of an XP PC. I'm using that guide here applied to a real-life example with screenshots taken along the way so you can see what is involved:-

Step 1 - Preparing the Old PC for imaging:
Tools needed
  • MergeIDE - a utility to get round the disk controller problem
  • Disk2VHD - a utility to create a disk image even on a working PC
  • SpaceMonger (optional) a graphical indicator of the size of the files on your disk 
First of all I created a folder on the old disk to contain the three utilities above. None of the programs require installation; they all run as-is. This makes them simple to use on the Old PC.

As we are creating an image of the old disk, we should get rid of any files and applications we don't need to keep the size of the image file as small as possibleEmpty the Recycle bin.  Get rid of Internet caches and temp files. (I used the excellent Spacemonger utility to show a graphical view of the old disk and from the view found that over 10G of data was duplicated on the disk(!)  By removing this data I reduced the size of the image file by 30% to 27.5G).



Do make sure that when you create the image file, whatever storage you use has enough free space to hold the image file produced by Disk2VHD and that you are not running any other software at the time you create the image. It may be quickest and simplest to attach a USB hard disk to the Old PC to contain the Disk image file and to simplify the transfer to the Host PC.

Step 2 - Making the disk image
Next, I ran the MergeIDE utility. According to VirtualBox's guide, this utility modifies the Windows Registry on the Old PC to relax the checks made on the boot disk controller. Just double-click on the MergeIDE.bat file in the folder. (It displays its output in German but should run without needing any input from us). Now we are in a position to run the Disk2VHD utility to create the disk image we will use on the Virtual PC. Navigate to the Disk2VHD folder and run the disk2vhd.exe program. (Don't be tempted to tick the box labelled Prepare for use in VirtualPC. That's for Microsoft's VirtualPC and does not work well with VirtualBox).

I was lucky to have enough room on the one drive in the system to store the image on the same disk, so I elected to store the disk image in the folder I had created to store Disk2VHD. Your situation will likely be different, so make sure you have enough space to hold the image file(s) you create. When you're ready, click on Create and the utility will the snapshot the drive and build a .VHD image of the disk as you've specified.  This will take a while so perhaps get on with some other work (like reading the other articles on my Blog?) or leave it running overnight.



When the program has finished, you'll be left with a very large file with the extension .vhd. You'll have to transfer this file to the Host PC ready to be made into a Virtual PC, which is Step 3. If you have installed Oracle's VirtualBox, you should find a folder in your User Area called VirtualBox VMs. In this folder Virtualbox creates a sub-folder with the same name as the PC you are virtualising (in my case my wife's PC was called Angua, so the folder will be called Angua). This is where you will copy the disk image file - but not yet. You'll see why in a second.

Step 3 - Making the Virtual PC
Assuming you have Oracle's VirtualBox already installed, open the Oracle VM VirtualBox manager ready to create the Virtual PC.


Click on New (top left) to start the New Virtual Machine Wizard and click Next. Enter the name you want to call the new Virtual PC (Angua in my case, but you should use the same name you used for the Old PC) and click Next.


Now select the amount of memory you want - adjust the slider or type in the amount. For an XP machine, if you have the spare, choose about 1G-1.5G (or 1024M-1600M) and click Next.

Now we should set up the hard disk. Remember you already have a disk image file so at this point you do not want Virtualbox to set up a disk - you'll do this later.  For now, just click Create and acknowledge the prompt that pops up by clicking Continue..


Now you need to set up the Virtual Disk.  Open the VirtualBox VMs folder and then double-click on the folder with the name of your new Guest PC. You should see two files.  A .box file and a .vbox-prev file.  Copy the .VHD disk image from the Old PC into this folder.

Now we need to tell VirtualBox to use this disk image.  In the VirtualBox manager, highlight your new Guest PC and click on Settings then on Storage. In the Storage Tree window to the right of Controller: IDE, click on the Add Virtual Hard Disk icon and Choose existing disk.


In the window that opens you should now see the disk image file that you copied over.  Select it and click Open


Step 4 - Starting up the Virtual PC
With the new Virtual PC ready to start we need to make one small change to the setup. Select the System tab and, under Motherboard, tick the 'Enable IO APIC box. This sets up the Virtual PC to work with the HAL that is likely to be in your disk image. Click OK to return to the VirtualBox manager, highlight your new Virtual PC and click Start. (Fingers crossed here...) 


Be warned: we're not quite done yet! Windows XP, if properly installed, will complain as you'll have changed all the hardware, so, depending on your licence, you may need to re-activate Windows.


If that wasn't enough, if you still have the old PC active on your network, your new Virtual PC will complain that a Duplicate Name exists on the network.


Don't you just LOVE Windows?? Let's take this through one at a time. We're almost up and running now.

Step 5 - Getting the Virtual PC running

Turn the old PC off to get rid of the Duplicate Name. (easy!)
Log into the Guest PC as you would have on the Old PC.  In my case, I clicked on Martin and entered my password.


When everything has settled, you can proceed to Activate Windows again if required.


On my installation the New Hardware wizard started.  And, surprise surprise, so did Windows Update.

For ease, I just selected  "Yes, now and every time I connect a device" and clicked Next.  I was asked to install a Video Controller and Base System Device.  Both failed, but that did not stop the Guest PC working - as can be seen with the two final screenshots below:



So there you are.  The whole process took a few hours - mainly for creating and copying the disk image, but setting up the Guest PC on the Host only took around 30 minutes.  The result is that the Guest PC runs slightly better than the Old PC did without the noise and without having to handle two PCs on the desk.

Now to get that application running natively on Windows 7.....



3 comments:

  1. Martin, I have been thinking about entering the virtualisation business for a while now. I have a pc with an i7 cpu and 16GB of RAM and a decent graphics card, and it runs Windows 8. Could I virtualise in a way that I could have an Ubuntu OS running in parallel? I have tried dual booting, but I want to be able to flick back and forth quickly. AT the moment I have a 256GB SSD for win 8 and there is a 64GB SSD which boots into ubunto, as well as a 1TB and 2TB pair of Spinrights. Could you mail any reply to me as well om my reddgate.co.uk address.
    Note I would like Ubuntu to run Snort and Acid all the time in the background.

    ReplyDelete
  2. David.

    You can't do what you propose with a simple albeit powerful PC like this. From what you are saying, the booting OS in Win8, so this is your Host environment. To run Ubuntu as a Virtual Guest on such a setup is trivial, but I doubt this is what you want. It looks like you are wanting an Ubuntu PC running Snort and Acid while occasionally wanting your Win 8 PC when you do any computing. This configuration is not virtualising; it's multiple PCs.

    The only easy way you can accomplish that would be to run a second low-power PC (perhaps an Atom-based PC or even a Raspberry Pi!) which is on all the time so that you can run Snort and Acid on that and keep your Win 8 PC to yourself.

    Hope this helps

    Martin

    ReplyDelete
  3. Hi
    The import of the VHDX file created won't attach to the VM, it needs to be converted to VHD 1st!
    See: https://superuser.com/questions/751954/how-to-convert-a-vhdx-file-to-vhd
    I am using VirtualBox version 5.1.26 r117224 (Qt5.6.2)

    ReplyDelete