Differencing disks sharing common immutable parent

This is for discussing general topics about how to use VirtualBox.
Post Reply
tkoster
Posts: 2
Joined: 11. Feb 2011, 15:24
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Linux, Windows

Differencing disks sharing common immutable parent

Post by tkoster »

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.
zeffantm
Posts: 7
Joined: 27. Jan 2011, 20:18
Primary OS: Linux other
VBox Version: OSE other
Guest OSses: Windows XP

Re: Differencing disks sharing common immutable parent

Post by zeffantm »

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.

vboxmanage createvm --name win7-05 --register

vboxmanage modifyvm win7-05 --memory 1024 --mouse ps2 --keyboard ps2 --ioapic off --ostype windows7_64 --nictype 82540EM --nic1 bridged --bridgeadapter1 "HP NC373i Multifunction Gigabit Server Adapter" --vram 128 --usb on --audio dsound --audiocontroller hda

vboxmanage storagectl win7-05 --name "IDE Controller" --add ide

vboxmanage storageattach win7-05 --storagectl "IDE Controller" --type dvddrive --port 0 --device 0 --medium emptydrive

vboxmanage storagectl win7-05 --name "SATA Controller" --add sata --hostiocache off

vboxmanage storageattach win7-05 --storagectl "SATA Controller" --type hdd --port 0 --device 0 --medium c:\vms\win7-2\win7-2-disk1.vmdk
tkoster
Posts: 2
Joined: 11. Feb 2011, 15:24
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: Linux, Windows

Re: Differencing disks sharing common immutable parent

Post by tkoster »

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
Posts: 2
Joined: 16. Mar 2011, 15:59
Primary OS: MS Windows XP
VBox Version: OSE self-compiled
Guest OSses: linux

Re: Differencing disks sharing common immutable parent

Post by gluni »

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
zeffantm
Posts: 7
Joined: 27. Jan 2011, 20:18
Primary OS: Linux other
VBox Version: OSE other
Guest OSses: Windows XP

Re: Differencing disks sharing common immutable parent

Post by zeffantm »

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.
gluni
Posts: 2
Joined: 16. Mar 2011, 15:59
Primary OS: MS Windows XP
VBox Version: OSE self-compiled
Guest OSses: linux

Re: Differencing disks sharing common immutable parent

Post by gluni »

ok thx, i was hoping for some fancy comfortable gui thing... :) but this will do of course.
Post Reply