Pages

Updating Ubuntu 11.10 to 12.04 gives problems with Samba and Greyhole

I run an Ubuntu server as a central home server holding all my media (photographs, music etc.) and the files we all use and share as a family in a safe and easy environment - rather than have different versions stored on each person's PCs and devices.. The server provides file shares via Samba and provides file resilience using Greyhole. Both have been configured and the server has run successfully for over a year since it was installed. Recently I upgraded my server from Ubuntu version 11.10 to Ubuntu version 12.04 LTS using the Ubuntu instruction Run 'do-release-upgrade' to upgrade All went well apart from two 'little' issues.
  • The first issue was that Zoneminder (a CCTV security monitoring program)  'broke' during the upgrade due to changes made within mySQL during the upgrade.
  • The second was that my shared folders stopped working.
While the first issue I can leave till another day, the second issue needed fixing right away as the server contents were needed that evening.

No pressure then.... ;o)

The first step I tried was to be clear about what had gone wrong. My Samba config was unchanged from before the upgrade and both services (Samba and Greyhole) had started without error. From my Windows 7 desktop I could access and browse my home directory without any issues. (I use this folder as a link between my Windows world and my Ubuntu world so this share is not maintained by Greyhole). However, while I could see all the other shares held on my server I could not browse into them to access the files. Instead, Windows 7 reported that it could not access the shares in an error window like the example below:
The next steps were to look at the logs for Samba on my server.
martin@homesvr:~$ martin@homesvr:~$ cd /var/log/samba/ martin@homesvr:/var/log/samba$ cat log.win7desktop
I noticed lots and lots of error messages like this:
[2013/04/14 20:09:42.217273, 0] smbd/service.c:869(make_connection_snum) vfs_init failed for service movies [2013/04/14 20:09:42.226322, 0] smbd/vfs.c:173(vfs_init_custom) error probing vfs module 'greyhole': NT_STATUS_UNSUCCESSFUL [2013/04/14 20:09:42.226446, 0] smbd/vfs.c:315(smbd_vfs_init) smbd_vfs_init: vfs_init_custom failed for greyhole [2013/04/14 20:09:42.226518, 0] smbd/service.c:869(make_connection_snum) vfs_init failed for service movies [2013/04/14 20:09:42.231051, 0] smbd/vfs.c:173(vfs_init_custom) error probing vfs module 'greyhole': NT_STATUS_UNSUCCESSFUL [2013/04/14 20:09:42.231172, 0] smbd/vfs.c:315(smbd_vfs_init) smbd_vfs_init: vfs_init_custom failed for greyhole [2013/04/14 20:09:42.231244, 0] smbd/service.c:869(make_connection_snum) vfs_init failed for service movies
However, for Greyhole there were no real issues:
martin@homesvr:~$ greyhole -S Currently idle. Recent log entries: Apr 14 20:09:52 7 sleep: Nothing to do... Sleeping. Apr 14 20:10:02 7 sleep: Nothing to do... Sleeping. Apr 14 20:10:12 7 sleep: Nothing to do... Sleeping. Apr 14 20:10:22 7 sleep: Nothing to do... Sleeping. Apr 14 20:10:33 7 sleep: Nothing to do... Sleeping. Apr 14 20:10:43 7 sleep: Nothing to do... Sleeping. Apr 14 20:10:53 7 sleep: Nothing to do... Sleeping. Apr 14 20:11:03 7 sleep: Nothing to do... Sleeping. Apr 14 20:11:13 7 sleep: Nothing to do... Sleeping. Apr 14 20:11:23 7 sleep: Nothing to do... Sleeping. Last logged action: sleep on 2013-04-14 20:11:23 (7s ago) martin@homesvr:~$ martin@homesvr:~$ greyhole -i /media/hdd2/gh: 0 kBps /media/hdd1/gh: 0 kBps /media/hdd3/gh: 0 kBps /media/hdd4/gh: 0 kBps ---
So this led me to suppose that the breakdown is between Samba and Greyhole, and, entering the following command:
martin@homesvr:~$ cat /etc/samba/smb.conf
shows me the config for the share I was investigating:
[movies]
    comment = Movie Library
    path = /share/movies
    browsable = yes
    guest ok = yes
    read only = yes
    force user = nobody
    force group = nogroup
    write list = martin
    dfree command = /usr/bin/greyhole-dfree
    vfs objects = greyhole
Note the dfree command line and the vfs objects line. These are the lines you have to put in the Samba config file if you want Greyhole to manage the files in a Samba share. The vfs objects line is an instruction to Samba to use the greyhole.so object to handle files on a Greyhole storage resource. Looking in the directory where Samba keeps the vfs objects you can see that in fact greyhole.so is a symlink to the actual file located elsewhere within the Greyhole libraries.
martin@homesvr:~$ ls -al /usr/lib/samba/vfs total 604 drwxr-xr-x 2 root root 4096 Apr 14 13:50 . drwxr-xr-x 5 root root 4096 Jan 2 2012 .. -rw-r--r-- 1 root root 31496 Mar 7 22:40 acl_tdb.so -rw-r--r-- 1 root root 27400 Mar 7 22:40 acl_xattr.so -rw-r--r-- 1 root root 15184 Mar 7 22:40 audit.so -rw-r--r-- 1 root root 23304 Mar 7 22:40 cap.so -rw-r--r-- 1 root root 23304 Mar 7 22:40 catia.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 crossrename.so -rw-r--r-- 1 root root 6920 Mar 7 22:40 default_quota.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 dirsort.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 expand_msdfs.so -rw-r--r-- 1 root root 19280 Mar 7 22:40 extd_audit.so -rw-r--r-- 1 root root 6920 Mar 7 22:40 fake_perms.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 fileid.so -rw-r--r-- 1 root root 52048 Mar 7 22:40 full_audit.so lrwxrwxrwx 1 root root 39 Jan 3 2012 greyhole.so -> /usr/lib64/greyhole/greyhole-samba35.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 linux_xfs_sgid.so -rw-r--r-- 1 root root 15112 Mar 7 22:40 netatalk.so -rw-r--r-- 1 root root 15112 Mar 7 22:40 preopen.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 readahead.so -rw-r--r-- 1 root root 23376 Mar 7 22:40 readonly.so -rw-r--r-- 1 root root 23304 Mar 7 22:40 recycle.so -rw-r--r-- 1 root root 27400 Mar 7 22:40 scannedonly.so -rw-r--r-- 1 root root 35592 Mar 7 22:40 shadow_copy2.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 shadow_copy.so -rw-r--r-- 1 root root 27400 Mar 7 22:40 smb_traffic_analyzer.so -rw-r--r-- 1 root root 19208 Mar 7 22:40 streams_depot.so -rw-r--r-- 1 root root 23304 Mar 7 22:40 streams_xattr.so -rw-r--r-- 1 root root 15112 Mar 7 22:40 syncops.so -rw-r--r-- 1 root root 43784 Mar 7 22:40 time_audit.so -rw-r--r-- 1 root root 23304 Mar 7 22:40 xattr_tdb.so martin@homesvr:~$
And, following the symlink, we find:
martin@homesvr:~$ ls -al /usr/lib64/greyhole/ total 56 drwxr-xr-x 2 root root 4096 Jan 3 2012 . drwxr-xr-x 4 root root 4096 Jan 3 2012 .. -rw-r--r-- 1 root root 13415 Jun 22 2011 greyhole-samba34.so -rw-r--r-- 1 root root 14560 Jun 22 2011 greyhole-samba35.so -rw-r--r-- 1 root root 14529 Nov 29 2011 greyhole-samba36.so martin@homesvr:~$
So, re-linking the greyhole.so to greyhole-samba36.so should fix this as I was running Samba 3.5.11 under the old 11.10 version of Ubuntu and I am now running Samba 3.6.3 under the 12.04 version.
martin@homesvr:~$ sudo ln -s /usr/lib64/greyhole/greyhole-samba36.so /usr/lib/samba/vfs/greyhole.so martin@homesvr:~$ ls -al /usr/lib/samba/vfs total 604 drwxr-xr-x 2 root root 4096 Apr 14 20:33 . drwxr-xr-x 5 root root 4096 Jan 2 2012 .. -rw-r--r-- 1 root root 31496 Mar 7 22:40 acl_tdb.so -rw-r--r-- 1 root root 27400 Mar 7 22:40 acl_xattr.so -rw-r--r-- 1 root root 15184 Mar 7 22:40 audit.so -rw-r--r-- 1 root root 23304 Mar 7 22:40 cap.so -rw-r--r-- 1 root root 23304 Mar 7 22:40 catia.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 crossrename.so -rw-r--r-- 1 root root 6920 Mar 7 22:40 default_quota.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 dirsort.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 expand_msdfs.so -rw-r--r-- 1 root root 19280 Mar 7 22:40 extd_audit.so -rw-r--r-- 1 root root 6920 Mar 7 22:40 fake_perms.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 fileid.so -rw-r--r-- 1 root root 52048 Mar 7 22:40 full_audit.so lrwxrwxrwx 1 root root 39 Apr 14 20:33 greyhole.so -> /usr/lib64/greyhole/greyhole-samba36.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 linux_xfs_sgid.so -rw-r--r-- 1 root root 15112 Mar 7 22:40 netatalk.so -rw-r--r-- 1 root root 15112 Mar 7 22:40 preopen.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 readahead.so -rw-r--r-- 1 root root 23376 Mar 7 22:40 readonly.so -rw-r--r-- 1 root root 23304 Mar 7 22:40 recycle.so -rw-r--r-- 1 root root 27400 Mar 7 22:40 scannedonly.so -rw-r--r-- 1 root root 35592 Mar 7 22:40 shadow_copy2.so -rw-r--r-- 1 root root 11016 Mar 7 22:40 shadow_copy.so -rw-r--r-- 1 root root 27400 Mar 7 22:40 smb_traffic_analyzer.so -rw-r--r-- 1 root root 19208 Mar 7 22:40 streams_depot.so -rw-r--r-- 1 root root 23304 Mar 7 22:40 streams_xattr.so -rw-r--r-- 1 root root 15112 Mar 7 22:40 syncops.so -rw-r--r-- 1 root root 43784 Mar 7 22:40 time_audit.so -rw-r--r-- 1 root root 23304 Mar 7 22:40 xattr_tdb.so martin@homesvr:~$
Given a moment or two to settle and re-trying the browsing from the desktop my access was restored. Checking the logs once more:
martin@homesvr:~$ greyhole -S Currently working on task ID 535303: write movies/Million Dollar Baby.m4v Recent log entries: Apr 14 20:36:50 7 write: File /share/movies/Million Dollar Baby.m4v is locked by another process. Will wait until it's unlocked to work on it. Apr 14 20:36:50 7 sleep: Only locked files operations pending... Sleeping. Apr 14 20:37:00 6 write: Now working on task ID 535302: write movies/Million Dollar Baby.m4v Apr 14 20:37:00 6 write: File changed: movies/Million Dollar Baby.m4v - 797MB Apr 14 20:37:00 7 write: Will use source file: /media/hdd3/gh/movies/Million Dollar Baby.m4v Apr 14 20:37:00 7 write: Loading metafiles for movies/./Million Dollar Baby.m4v ... Apr 14 20:37:00 7 write: Got 2 metadata files. Apr 14 20:37:00 7 write: 2 metadata files loaded. Apr 14 20:37:01 7 write: File /share/movies/Million Dollar Baby.m4v is locked by another process. Will wait until it's unlocked to work on it. Apr 14 20:37:01 7 sleep: Only locked files operations pending... Sleeping. Last logged action: sleep on 2013-04-14 20:37:01 (4s ago) martin@homesvr:~$
And I am now successfully browsing all my shares. This is something to be aware of as Greyhole is not updated or checked during the OS upgrade to Ubuntu 12.04.

I hope that this helps someone.

Addendum...
... if anyone is interested, the Zoneminder issue was actually a bug in the upgrade of the Zoneminder application to 1.25.0-1.

The bug is registered here:
https://bugs.launchpad.net/ubuntu/+source/zoneminder/+bug/940632

And the workaround is as follows (you *did* write down your MySQL admin password during the installation, didn't you?):

martin@homesvr:~$ mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 63 Server version: 5.5.29-0ubuntu0.12.04.2 (Ubuntu) mysql> GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' IDENTIFIED BY "zmpass"; mysql> quit Bye martin@homesvr:~$

So that's my server successfully updated to Ubuntu 12.04LTS with both issues now resolved.

Sennheiser Headphone renovation for next to nothing...

I've just finished renovating a vintage pair of Sennheiser HD420 headphones that I've owned for over forty years. The renovation was cheap; it was simple and took no more than half an hour to complete.
But why waste time on a forty year old piece of electronics? Surely modern headphones are much better and only a click of a mouse away? Well, maybe, but I love the sound of these old phones and they are so light on my head I can wear them for hours - even with glasses.
I bought my Sennheiser HD420's when they first came out in the late seventies. Since then, they've been my choice in headphones over any newer headphones I have bought or listened to. They are one of the most openly transparent, detailed headphones I have ever listened to - if perhaps a touch light at the bottom end. They do benefit from being driven from a higher voltage source such as a hi-fi amp rather than straight from an iPod or MP3 player but they still sound good on portable devices.
So what was wrong with them? The foam earpads had perished and had literally gone to pieces inside the cloth covers and the headphones were becoming uncomfortable to wear. I tried looking on Sennheiser's web site - and their support site - for replacement pads, but it appears that you cannot get hold of them any more. Such a pity.

There are other HD420 owners on the Internet also seeking replacement earpads so I thought I'd see what else I could do - and hope that my findings are of use to others.

The Sennheiser HD420 earpieces come in three parts. There's the transducer in its plastic housing, an acoustic foam insert and a cloth cover that holds the foam to the transducer. As long as the cloth cover is intact and the headphones work, then all you have to do is replace the pads.
  1. First measure the earpiece diameter (they are 80mm)
  2. Next search Amazon for "80mm replacement earpads"
  3. Buy one of the items that come up in the results
That's the easy bit.

When they arrive you have to replace them. This needs patience, fingers, kitchen paper and an old toothbrush. No other tools or you risk damaging the cloth cover or the headphones.
First you must tease off the cloth covers. Use your thumbnail and carefully ease the plastic surround all round before gently sliding the surround off the transducer.
When the cloth cover is off, clean as much of the old ear pad from the cloth as you can (in the picture all that orange crud is the old earpad).
Now, with a toothbrush (and nothing else!) gently brush all the compressed and rotten old earpad from the transducer. Be careful - the white in the transducer is material and this can easily be damaged if you use too much force. Remember it is forty years old!!

Here you see the new earpad with one of the cloth covers
Here you see the new earpad in position over the transducer
To re-fit the new pad and the cloth cover, first tuck the pad into the cover as seen here.
You now need to gently get the cover back on the transducer. I did this by holding the plastic surround in place with one finger while I gently eased the surround back into place around the transducer. The hardest part is the last inch so make sure that the last inch is away from the wire and the headband so you have the most control. Don't use tools or too much force or you'll tear the cover. Of course you can take the transducer off the headband (it just pulls off, but remember it is old so it could be brittle) and you can also pull out the wire, if this makes it easier. I decide not to do this and did not have any real issues, but the choice is yours.

Finally the restored Sennheisers, all padded out and once again, fit and ready to listen to.

Total cost?  less than £3.00 and under thirty minutes. Satisfaction?  Priceless.  :)

How the train companies are not helping you work from home.

One of the things the Government, the railway companies and Transport for London (TfL) all acknowledge is that the trains into London are frequently overcrowded and that investment is needed to improve this. Surrey County Council, for example, has recently commissioned a rail strategy to tackle what they state is an urgent need to reduce overcrowding. A key aim of this strategy will be to explore how overcrowding can be tackled.

One obvious strategy that could contribute to a reduction in overcrowding is the strategy of ‘working from home’. Admittedly, this approach cannot work for everyone as many people need to be present at their place of work to carry out their duties, but there are many others who usefully can carry out much of their work at home – some office workers, for example. Modern technologies exist that make it easy for an office worker to work securely and effectively from home and the practice has great benefits for the worker, his or her employer, the environment – and the transport infrastructure!

Typically, a home worker:
  • Has an improved work/home balance – they spend more time with the family
  • Is more environmentally friendly – they make fewer commutes, there's less traffic, they save fuel
  • Is more productive – there is less distraction, less stress and more flexibility
If everyone could work one day a week from home then at a stroke the passenger demand would fall 20% and this would greatly ease congestion – particularly while the Rail companies strive to upgrade their facilities. But these same rail companies don’t offer any real incentives to encourage commuters to work from home.

Let me explain why:

The commuter’s season ticket is meant to offer the poor commuter the chance to get to work for a reduced price. Annual Season tickets (at least on my service – run by Southern Rail) are based on a simple premise that you pay for 40 weeks travel and the remaining 12 weeks in the year are therefore ‘free’. This premise conveniently skips over the fact that of those twelve weeks, you are likely to have four or five weeks holiday and another week or so of Public holidays. This means that, while you are paying for 40 weeks of travel, you only effectively use the ticket for about 46 weeks of the year – the discount is therefore not quite as generous as it seems.

Now. Let’s say you buy a season ticket and are able to work from home. In this situation you actually LOSE money as a season ticket is costed on the basis of five return journeys a week and is based on a timed period of validity – typically weekly, monthly or annual. I can supply the workings but for my particular service, my annual season ticket costs about £2,500. On average, if I take into account my holidays and work a full five-day week, that costs me £11.14 per day (or £14.28 if I include the London Underground). If I work one day a week at home, regularly, then the daily cost jumps by 25% to £13.96 (or £17.89 with the Underground).

Hardly an incentive, is it?  Particularly when you're helping them out by not travelling.

What is needed is an alternative to the season ticket that gives you the ability to bulk-buy tickets in advance rather than the more common type of commuter tickets that allow unlimited travel between two dates.  This bulk-buy train ticket is sometimes known as a carnet.  The Rail Companies talk about these tickets but they're either restricted in use (First Capital Connect) or they just don't exist (Southern Rail) - although interestingly, I did find this snippet on Southern Rail's "Meet The manager" pages from March 2011:

Southern will be introducing a new way of ticketing called ITSO smartcards. These new plastic cards allow tickets to be loaded directly onto the card, similar to the Oyster card in the London area.
We will also be launching new season ticket products that will work on a carnet based system, therefore if you buy a weekly ticket which is valid for 7 days and you only worked 3 days a week, essentially you can use it for 2 weeks. (i.e. carry over the remaining days).
Initially these new products will be introduced as a pilot scheme across some parts of the Southern network from June 2011, and then over the course of the next 18 months, rolled out across our entire network.
By their reckoning the rollout should be finished now.... But nothing.  No sign of the ITSO smartcard, either.  Perhaps Southern could provide us with an update?

Transport for London (TfL) are just as bad.  You can, of course, use the Oyster card, the ideal technology to use for a Carnet, but there is no bulk-buy capability here even on Pay As You Go.  I even #askedBoris on Twitter:
  • @savcom - @MayorofLondon #askboris can I ask what can be done with season ticket costs for those who work from home one day a week? 

Regrettably no reply.... 

I'm not alone in wanting this.  I found that The Guardian Money Blog talks about Carnet tickets and the writer there expresses her dismay at how difficult these are to find.  More recently, Roger Evans of the Greater London Authority Conservatives has written a report (downloadable here) in which he calls for a step-change in TfL’s attitude to home working and flexible working.  He states that “One of the problems is that once people have paid for a Travel Card, there is no financial incentive to use it for less than 5 days a week".

The London Evening Standard covered the report in this article.  They lead with the headline "Part-time travelcards would ease Tube overcrowding, say Tories" and go on to state that "Commuters should be offered flexible travelcards and rebates on monthly tickets to help curb overcrowding on the Tube". To give you an idea of the scale of travel every Monday more than 3.4 million journeys are made by Tube and over six million on London’s buses. The capital’s population has increased by 12 per cent to 8.2 million in the past decade and is likely to reach nine million by 2018.  So things are only going to get worse.

Mr. Evans wants to see the introduction of a three-day per week Travelcard which, he says, would significantly help those who work from home.  While a three-day-a-week travel card may help, surely it is better to think in terms of a bulk carnet approach where a commuter who works two days a week from home buys a carnet of (say) 240 tickets in one go and then simply uses them as he or she needs to (if the commuter travelled into the office three days a week, they'll use those journeys up in 40 weeks - the same time as used for season tickets).  If the commuter has to or chooses to make more journeys their card will just use up the journeys more quickly and the commuter will need to recharge their card more often.  This may actually be a better way for ALL season tickets to be issued and should ensure we're all using and benefiting from the system fairly.

There is NO reason why the systems in place cannot be re-thought or re-coded to provide this flexibility as Oyster card and Smartcard technologies provide the ideal  mechanism for this to be achieved, so it’s now time for the Train Operators, the Mayor and TfL to make it a reality. 

Now it's your turn.  if you want something like this to help control the costs of your commute then you should all urge your Train Operators, Boris Johnson and TfL to adopt these proposals. Let them know that we want them to re-think the Season Ticket and to promote fairer ways of supporting the Work from Home movement and to encourage us all to make fewer journeys - after all, if you don't ask, you don't get. 

Let me know by comment if you've approached them and if you've had a response. I'll be doing the same.

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.....