Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have a couple of test VMs which we use to test software on. We would like to have a virtual machine revert back to a saved state everytime the VM restarts.

I believe virtualbox calls this feature "Read-Only Mode". I know I can manually revert to a snapshot each time however I would like to automate this process.

Does anyone have any ideas?

Thanks

share|improve this question
add comment

4 Answers

Yes, you can make your reference .vhd read-only and attach a Differencing Disk:

Differencing - Differencing is a concept which involves a parent disk and a child disk. The parent disk contains a baseline hard disk image with the operating system and perhaps a range of applications and data installed. Once this baseline parent disk is configured, a differencing disk is assigned as a child. When the virtual machine to which the disk is assigned runs, any changes made the baseline parent image are actually stored on the child differencing disk, leaving the parent disk unaltered. Multiple child disks may be assigned to a parent disk allowing multiple virtual machines to share the same parent disk. Differencing disks may also be chained together. The changes contained in a differencing disk may be merged into the parent disk. Alternatively, a new virtual hard disk may be created containing the merger of the parent disk and the child disk, thereby leaving the parent disk unaltered. When creating a differencing disk, the parent disk will need to be specified. The size of the differencing disk increases as space is required. Differencing disks may also be compacted to free up unused space (see the section below entitled Modifying Existing Hyper-V Virtual Hard Disks).

Link.

This has a performance penalty though, like running off many parent snapshots, but it most probably will not be noticeable unless your server is very busy.

I cannot remember if you can set the VM to always start from the parent image, but I think you can. Someone must have made a PowerShell script to do it at worst.

share|improve this answer
add comment

Use something like Deepfreeze, ProtectOn Pro, or Steady State. All of these packages will revert any changes on startup. They're all easy ways of doing this without killing performance.

share|improve this answer
add comment

What about a simple copy-replace scripting on start-up or shut-down of the VM?

share|improve this answer
add comment

Microsoft's answer to questions like this is System Center Virtual Machine Manager with the Self Service Portal.

In it you create a reference template (usually just a syspreped VM) and users can dynamically create new machine based on that image through the SSP (a webpage). It's extremely convenient, allows for a reboot without losing everything. You can configure an image and store it in a library for later use, destroy it, checkpoints and really a lot more.

That said, it isn't free, but isn't very expensive if you're going to use it's features.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.