RSS Feeds

Building a VMware Appliance Playpen

I decided to use Ubuntu 6.06 as a playpen for building OOo. However one of the things about a playpen is that you want to make sure that any changes that you make do not contaminate your main working system.  Until recently this really meant having a dedicated test box, but thanks to the introduction of free virtualisation products from VMware and Microsoft , the need to have a separate test box is now history — as long as you have enough memory and disk on your host system.

There are some differences between the VMware and Microsoft products, the main two being that (i) VMware only offers a limited version of its desktop virtualisation product for free whilst Microsoft offers its fully featured Microsoft Virtual PC (MVPC) product, and (ii) as MVPC is primarily targeted at hosting Windows OSs, its Linux support is a little lumpy (especially around virtualised graphics and display driver interoperability).  I first evaluated Ubuntu after downloading (using bitTorrent) a pre-packaged appliance from a link on the VMTN Appliances page.   The only problem was that appliance this had a disk size of 8Gbytes, which is really too small to do a full OOo build. So then I decided to do an install of Ubuntu into a bare MVPC VHD, but I got bogged down in problems getting Ubuntu to work with the MVPC graphics adapter.  After some head scratching and lots of Internet searching I then decided to go back to my Ubuntu appliance and resize its disk to 12Gbytes.

Resizing the disk is a two step operation.  First, in order to resize your virtual disk container, you need to use the vmware-vdiskmanager.exe utility.  Use the -help option to give you the command to type.  [Unfortunately you won't find this in the VMware Player distribution. However it is part of the tools supplied with either the VMware Workstation or the free VMware Server product.  One easy way of obtaining it is to temporarily download and install the Server, use the tool, then  you can remove the Server product.  Note that if you do this you may first need to temporarily remove Player.]  This resize takes only moments, and once done the VHD will have a "physical" size of 12Gbytes even though the allocated partitions are unchanged.

The second step is the now to resize the partitions to extend the primary partition to take of the extra 4Gbytes.  To do this you need to download a nice utility called GParted from SourceForge.  Unfortunately though GParted is already pre-installed on the Ubuntu image, unlike Partition Magic, it cannot resize mounted partitions.  Hence you will have to go through the following palaver — but what the heck GParted's free, and this all takes about 15 mins. The download is a 30Mbyte ISO image of a CD bootable Linux image containing the partition resizing utility. Player supports direct mapping of ISO images onto the virtual CD-ROM, so you don’t need to blow this onto DVD or CD.  However, you will need to tweak your VMX file  (The full VMware Desktop documentation explains this, but they assume that the typical user of Player won’t need to do this sort of stuff. ).  

ide0:0.deviceType = "cdrom-image" 
ide0:0.fileName = "<what ever your image path is>"
ide0:0.present = "TRUE"
ide0:0.startConnected = "TRUE" 

You can hit ESC during the Bootup POST phase to select CD-ROM boot, but I found it a real pain trying to set focus to the VMware session and hit ESC quick enough, so in the end I did a reboot and hit F12 to get into the BIOS then temporarily promoted the virtual CD to the first boot device ahead of the VHD.  Now after reboot, the grub loader will take you into the minimal GParted Environment.  The boot sequence is quite long and you might think that it has hung, so you need patience.  My laptop did this for almost a minute whilst the OS booted.  I also had some problems with the display driver on my laptop, but could work around this because the GParted boot process allows you to select the Manual display driver and pick a minimum SGA compatible device (you aren’t going to be needing high performance graphics during this resize are you?)  Once you get into the GParted full GUI which looks similar to Partition Magic’s. You can now resize your VHD partitions by scheduling the following steps: This can be scheduled as a sequence and when you action it GParted then takes about 5-10 mins to do the move.

  1. Resize the extended partition to include the end 4Gbyte

  2. Relocate the swap logical to the end of the extended partition

  3. Reduce the extended partition, moving its start up to the start of the swap logical partition

  4. Resize the system primary partition to take up the 4Gbyte gap now created.

Once done, you can reset the boot sequence and boot from the VHD.  You might also want to reset the VMX file or set the ide0:0.present and ide0:0.startConnected parameters to false.  Once you’ve done this you can boot the Ubuntu Appliance and log on. (The user and password were Ubuntu). A quick df will now show that you now have a 12Gbyte files system and are in business.   The only other thing that I had to do was to resize the screen to a default 1024x768, because that the default size of my Laptop display.

One issue working with VM appliances is that you will find that transferring files to and from your host machine is a bit of a pain with VMware Player, so a couple of tricks can be used here.  The first is to use a FAT formatted USB stick.  (You will find that you can enable and disable this in the Player Device menu (remembering to sync your file systems first) thus passing it between the host and the appliance).  The second is to run an FTP server on one of the machines.

Also see my article Error Handling in VBScript - Part II for more details.

Comments

  • 1.
  • At Tue 14th October 2008, 8:35 pm,
  • Franklin S Werren wrote:
Hi Terry;
I am working on a Ubuntu Host and I am using Virtual Box... So here is the question....? I want to redused the size of my VDI disk to it's actual size on the hard drive. and here is what I get....
root@franklin-laptop:/home/franklin/.VirtualBox/VDI# VBoxManage modifyvdi xp.vdi compact
VirtualBox Command Line Management Interface Version 2.0.2
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.

[!] FAILED calling virtualBox-&gt;FindVirtualDiskImage(filepath, vdi.asOutParam()) at line 3320! [!] Primary RC = NS_ERROR_INVALID_ARG (0x80070057) - Invalid argument value [!] Full error info present: true , basic error info present: true [!] Result Code = NS_ERROR_INVALID_ARG (0x80070057) - Invalid argument value [!] Text = Could not find a registered VDI hard disk with the file path '/root/.VirtualBox/VDI/xp.vdi' [!] Component = VirtualBox, Interface: IVirtualBox, {557a07bc-e6ae-4520-a361-4a8493199137} [!] Callee = IVirtualBox, {557a07bc-e6ae-4520-a361-4a8493199137} error: Hard disk image not found
This is driving me NUTS...
Thanks Franklin S Werren <a href="mailto:admin@chautauqualake.net">admin@chautauqualake.net</a>
PS sorry about posting here but I could not find an e-mail for you... Ann my Account on virtual box forum was disabled for inactivity...