Can I use one virtualbox disk for multiple machines?
I'm not sure what search term to use and skimming through the VirtualBox manual didn't help me either, so I ask my two questions here...
My setup is this: PC with dual boot into Windows 7 and a Debian operating system (both 64bit). I've created a virtual machine (Kubuntu, 64bit) under Windows and put it's VDI file on a SMB share of my NAS.
Then I created a VM under linux using the same settings for memory etc and assigned the existing VDI file to it.
My idea was that I could use that virtual machine from Windows and Linux as well. (1) Is this generally something that should work without problems?
I noticed that snapshots get me into trouble because they appear to be not visible from the other operating system: The snapshots I took after installing the guest system are not visible under Linux. That's why I shut down the VM after usage and not save its state while it's running.
My current problem is this: I have used the VM under Windows first, then under Linux. Now it will only start on Linux. When trying this on Windows the guest OS detects some kind of hard disk error and fails to boot because it cannot mount its drive. Obviously the virtual hard disk won't fail so it must have something to do with me using it under Linux.
(2) How can I fix that?
Update: It also looks like any changes I made in the VM under Linux have been reset by trying to boot it under Windows. Looks like it's back to the latest snapshot. I'm confused...
Update
The answer to my first question can be found below. In short: It works, as long as you don't use snapshots.
The answer to my second question is this: Under Windows set the VM back to the latest snapshot and then discard the snapshot so it gets merged. There should be no snapshots left at the end. If you have multiple snapshots, discard the earliest ones first (Snapshot 1, then 2, 3, ...). I'm not sure what happens if you start at the end (.., 3, 2, 1).
This of course leads to some data loss since you revert all changes since the last snapshot. But at least the VM is usable again.
Solution 1:
Yes, you can share the VDI file as you're doing because you've only got one instance of VirtualBox accessing the VDI file at a time.
However, there is another caveat that you should take into consideration - you cannot share VDI files once you create a snapshot.
Even though this thread is a little old, it should give you a reasonable understanding of why you cannot share a VDI file once you've created a snapshot.
So, avoid snapshots and you should be able to share your VDI file between your Windows and Linux installations.
Solution 2:
To correct some of the miss information on this post.
- You can share a single VDI (Virtual Disk Image) between multiple machines.
- These machines can ALL be running at the same time, with divergent changes.
- Also, they can all take advantage of Snapshotting.
- Even after a snapshot has been taken, you can branch and spawn new machines from any point in a machines history.
I wrote a post a while back just for this...
http://blog.mrverrall.co.uk/2010/06/spawning-many-virtualbox-machines-from.html
Also see the previous post on "Cloning VMs with Multiple Snapshots in VirtualBox" Which would have got around the original posters main issue... i.e. moving a machine, snapshots and all to a new OS.
:)