views:

377

answers:

3

Hi,

I would like to script a build of a virtual machine from a base image, with a number of files and folders being copied across to the target machine, and some software also installed on it. Is this possible? Which technology is best suited to this - VMWare, Virtual PC/Server or Virtual Box? The solution has to run on WS2003 or WS2008, so the new Windows Virtual PC is not an option for me.

Thanks, MagicAndi.

A: 

The solution I have came up is to bake all the changes I need to make to the virtual machine into a custom MSI, built up using the Windows Installer XML (WiX) toolset. To install third-party software on the virtual machine, I can either track the changes to the OS by each application installer (using Process Monitor from SysInternal Software) and replicate them into my own custom MSI, or I can use a script (like this AutoIt script) to install the software from a shared directory. I also am looking into using White and PowerShell for scripting.

MagicAndi
+2  A: 

I've used VMWare for this in the past, particularly the free VMWare Server product. Create a VM and install the OS as usual, then use sysprep to package the machine and feed it an unattend file. After sysprep shuts the machine down, save it off as your base image.

When you want to create a new image, make a copy of your base image, then use the vmware-mount tool to mount the newly copied image as a drive letter. Open up the unatend file and change out the machine name, etc, and added any additional commands you want to run after the machine is powered on. Then vmware-mount /d and power on the virtual machine.

Script all this together and you've got a one-click machine generator.

I'm a fan of VWmare server -- it's free, and the vmx file format is easily understood.

lordbrain
Lordbrain, thank you for your answer. Using the VMware-Mount tool looks to be an option to load the installer files, etc. However, I think the vmrun utility, detailed at http://www.virtuatopia.com/index.php/Controlling_VMware_Virtual_Machines_from_the_Command_Line_with_vmrun, looks to be more useful in running scripts and configuring the guest machine for use, specifically in the automated build scenario I am considering. Now, if only there was way of doing the same in Microsoft VPCs!
MagicAndi
Lordbrain, the bounty has attracted a few more people to view this question, but if no one else has contributed an additional answer by Friday, I will accept your answer and award the bounty to you. Thanks. +1.
MagicAndi
A: 

It look like it may be possible to automate the creation of virtual images using MS Virtual Server 2005. The following articles detail the use of PowerShell scripts to automate the creation of virtual images:

From part 2, in the section Configuration Tests on a Virtual Machine, it seems possible to transfer files and schedule scripts to run. Using these articles as a basis, it should be possible to automate the building of a MS virtual image in the same way as lordbrain described for a VMware image.

MagicAndi