Big Switch 6: Virtually there.

OK a quick recap from my last post, where I realised that then next step was going to take some explaining … A week or so went by without incident and it was time to consider the final stage: moving Windows to a virtual machine and getting rid of the old Windows partition. Here are the main stages.

  1. Make a windows install CD from the install files on the windows partition (Thinkpads don’t have an install CD, they use an Install partition)
  2. Install vmware on Ubuntu and make a Windows Virtual Machine.
  3. Delete the old Windows and IBM Install partitions
  4. Re-arrange the remaining partitions to suit the new arrangement.

Making the Windows Install CD.

This is a little bit complex because I have an IBM Thinkpad. The OS on these comes as a 4Gb rescue partition which you can boot into and restore your Thinkpad to factory condition. I made the DVDs and CDs to complete this, but actually I didn't want to use these, as it a) reformats the hard disk into a single partition + recovery partition, and b) installs a whole raft of IBM drivers widgets and bloatware that I don't want. Nevertheless I have an OEM license for Windows XP home which I'm entitled to use on this machine, so the question is how to get it installed in a Virtual machine.

The answer I found in several blog posts and howto articles, which I've subsequently lost. You can get most of the info here http://www.howtohaven.com/system/createwindowssetupdisk.shtml

Here is how I modified that info and the main steps I took:.

  1. Start with the files installed in c:\i386. Copy these to another location so you can work on them without breaking anything (despite the fact you're going to vape your windows install in a couple of hours anyway)
  2. With the files in the new location (say d:\xpinstall) you need to add some plain text files to tell it that the install is an OEM install (see reference article above)
  3. Slipstream in Service Pack 2.
  4. Use nLite to slim down the installation to the essentials, (we don't need no stinkin' helpfiles!) and then build you a boot CD iso image.

VMware Install and setup

Meanwhile, back in Linux Mint / Ubuntu, we have to install vmware server. This is done pretty easily through Synaptic. If you don't see it in there, you'll have to enable the third party software repositories. I chose VMware server as opposed to Workstation or Player because it was freer than Workstation, and it had more functionality than the Player.

Once vmware Server is set up, you need to start it from the item it put in your Start Menu, and connect to localhost. From here you can create a new machine. I opted to use a dynamic container with a max size of 8Gb, although I could have got away with less. I set the CD Drive to point to the .iso image I created above (brilliant feature!), and then booted it up. Windows installed like a charm, and using the OEM licence key on the bottom of my Thinkpad, it was all legal. I also set up the Network connection to NAT to my network so that the Windows machine is never directly exposed to the Network / Internet and the Ubuntu install effectively acts as a router. VMware takes care of all this for you, so you don't have to think about it too much. However if you want to run a server in VMware, you'd probably use the direct, non-NAT connection.

The final setting you may want to play with is the memory allocation. I have 1Gb of RAM, and I allocated half of that to the virtual machine. Windows runs fine in that, and this is a very low spec machine.

Once Windows is installed, obviously you have to do all that updating, and installing of AntiVirus. I also installed a couple of tools I use and my accounting software. Within the virtual machine, I set up a Truecrypt container for my accounts data, and then wrote a quick script to sync this back up to my Ubuntu installation using scp. This means once I've finished doing my monthly accounts I can just hit the button and it backs it up for me.

Having set all this up, I took a snapshot, and backed up the entire VM to an external hard disk, so if I ever need to recover it, I can do so in minutes. Very cool.

Deleting the old partitions

Once again, I left this for a week or so until I was sure things were working smoothly. During that time I also experimented with a couple of other VM images – I built one of Centos 5 server so I could prototype some development, and tried out Zimbra mail server. Unfortunately the Zimbra server comes as an rPath device, so you don't really get to play with it properlly. Anyway, this virtualization stuff is great. I wish I'd done it properly sooner.

The trouble with having all these virtual images is they take up a lot of space, so I was now beginning to run out of disk space. Time to get rid of those unused partitions.

The tool for the job is the gparted live CD, which I hadn't used for about a year. I was pleased to see that the latest version, despite a modest increment in its version number, is streets ahead of the last one I used. Great job guys!

So here's what we do.

  1. Plug in an external USB drive to back up onto.
  2. Boot from the gparted Live CD, and make sure the USB drive is mounted. eg.
    • mount -t vfat /mnt/sda1 /mount/usb
  3. Start partimage from the menu, and use it to back up the partitions we're going to delete. Hack them into 2Gb chunks as suggested by partimage, as we're backing up to a VFAT drive. A 20Gb partition took about 20 mins. That's fast if you've ever used something like Encase …
  4. Back up any live data partitions you've got as well, just for good measure. You can delete them if all goes well
  5. Use Gparted to delete the partitions on the disk that you don't want.
  6. Reboot the computer and check you got rid of the correct ones …
  7. OK now to organise them

Rearranging the partitions on the disk

Reboot into the Gparted CD. In my case what I now have is

  • a 10 Gb root Linux partition (/) on /dev/hda5
  • a 1 Gb swap partition on /dev/hda6
  • a 100Mb /boot partition on /dev/hda7
  • a 15Gb vfat data partition on /dev/hda3 which is in an extended partition, /dev/hda4
  • Two chunks of free space.

Moving partitions around in gparted is just a case of copying and pasting. Really. The potential for disaster is high, but if you're all backed up, then there's nothing to lose right? I cut and pasted, and re-sized and re-organized, until I was left with this:

  • /dev/hda1 – 20Gb – Linux main system (moved and enlarged)
  • /dev/hda2 – 100Mb – /boot partition (moved)
  • /dev/hda4 – 1 Gb – swap partition (moved)
  • /dev/hda3 – Extended partition containing
    • /dev/hda5 – 17 Gb Data partition (enlarged)
    • /dev/hda6 – 17Gb /home partition (newly created to house all the VMs)

Having done such major reconstructive surgery I knew I was in for a few glitches on boot up, but I knew I could get around them eventually.

This post has got a bit long … its continued here.

Leave a Comment