R – Automate/Script Building a Virtual Image

automationscriptingvirtual-pcvirtualizationvmware

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.

Best Answer

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.