I am having big trouble setting up a set of VMs that use differencing disks that share a common immutable parent. I always seem to end up with leaf disks disappearing out of the media registry after snapshots are taken and the VMs becoming 'inaccessible'.
My question is, no less: "What is the correct procedure for setting this up (in 4.0)?"
For those interested in what I was trying, this is known not to work:
'createvm --name test1' and 'storageattach --medium base.vdi --mtype immutable'
According to the docs, this actually attaches a differencing disk with base.vdi as the parent. Examining the vbox/xml confirms this to be true, as intended.
'createvm --name test2' similarly.
This VM gets a different differencing disk from the same base, as intended.
At this point, both VMs run. I 'modifyhd --autoreset off' both differencing disks so they can now diverge.
As a technical note, the MediaRegistry section in test2's xml is empty and its disk is actually registered in test1's xml (presumably because that's where the parent is registered).
Now, take a snapshot of test1 and test2. If you now open the QT manager, test2 will be 'inaccessible' because the leaf disk it would use after the snapshot was taken is not registered anywhere (it is not inside test1's MediaRegistry section for some reason). Also, in order to put it into test1's xml manually during the 'clutching at straws' phase of this exercise, I noticed that the auto-reset on test1's image was changed back to 'on' after the snapshot was made, which is not what I intended.
First off, create an immutable disk. Here's how I did that:
To make a drive immutable:
Get the prototype VM configured exactly as desired for the immutable VM. Export it
Open VM VirtualBox Manager
Select the VM
Select File, Export Appliance
Select the machine to export, Next
Browse to and select where it should be exported to (use the path where the source VMDK file resides.) and name it the same as the .box file. Next
Finish ( this will take a few minutes) Delete the existing VM that is listed
Select the VM
Right-click, Remove
In the “VirtualBox - Question” dialog box, choose “Remove only”
Go to the directory where the VM files exist
Delete all the files except the *.OVA file Import the file to create a new VM
From the menu select File, Import Appliance
Click on Choose and browse to the OVA file that was just created, Next
NOTE: That browse dialog box often doesn’t show the contents of the selected folders. You may have to type in “C:\” to get them to show up.
Click Finish. The import will take a few minutes.
When it finishes DO NOT START THE VM! Delete the VM that you just created
Select the VM
Right-click, Remove
In the “VirtualBox - Question” dialog box, choose “Remove only”
Go to the directory where the VM files exist
Delete the *.vbox file Convert the disk to immutable
Open up a DOS box
Update the PATH to include “c:\Program Files\Oracle\VirtualBox”
Change to the directory where your VMDK files are located
Verify the name of the VMDK file you need to modify
Type in the following command:
vboxmanage modifyhd <filename.vmdk> --type immutable Create a new VM
Click New, Next
Name the machine the same as the directory where the VMDK file is located (i.e. c:\VMs\Win7-1) and select the OS and version, Next
Set the memory amount, Next
Select “Use existing hard disk”
Browse to and locate the existing VMDK file
NOTE: That browse dialog box often doesn’t show the contents of the selected folders. You may have to type in “C:\” to get them to show up.
Click Next, Finish
To create additional differencing VMs based on the immutable:
In this example I called my immutable VM "win7-2" and a new differencing VM "win7-05". These are actually excerpts from a batch file I created.
Ah so the key is to keep a parent VM that is never actually run only to store the media registry for the other VMs that you bud from it. I might give it a try this weekend.
gluni wrote:thx for the infos. would you consider posting or making available the script you are talking about?
would be great and confortable for me.
thx
Jeff
Jeff, you've pretty much got the script right there. Just use those excerpts as part of a larger script, with just the names of the new differencing disks changing.
I didn't do anything magic, as I haven't done a lot of scripting lately.