Sharing Guest between dual booted Hosts

This is for discussing general topics about how to use VirtualBox.
Post Reply
stylekilla
Posts: 4
Joined: 26. Aug 2021, 02:11

Sharing Guest between dual booted Hosts

Post by stylekilla »

Hi all,

Either I'm really bad at searching around or there actually isn't much information on the topic.
And apologies if this is in the wrong forum, all the others were unique to one particular OS, so I thought it best to put it here.

I have two host OS's on the same computer (dual booted through GRUB).
1. Windows 10 Pro 64bit (Host) with VirtualBox 6.1.26 r145957
2. Kubuntu 20.10 64bit (Host) with VirtualBox 6.1.22_Ubuntu r144080

I created and have been running a guest OS (also Windows) on the Windows system:
1. Windows 10 Pro 64bit (Guest)

Today, I've attempted to load the virtual machine on the linux host and I get the following error with no log files produced:

Code: Select all

Failed to open a session for the virtual machine Admin.

The VM session was closed before any attempt to power it on.

Result Code: NS_ERROR_FAILURE (0x80004005)
Component: SessionMachine
Interface: ISession {c0447716-ff5a-4795-b57a-ecd5fffa18a4}
Now, here's the interesting thing (or at least interesting to me).
The VM always starts in windows without an issue.
I only get the above error on Linux.
To fix it, I have to load Windows, start and shutdown the VM, load back into Linux and it starts working again.

Why? Any ideas how this be fixed/avoided?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Sharing Guest between dual booted Hosts

Post by scottgus1 »

Why you get that error puzzles me. Is the VM's .vbox file registered in both host OS's? If so, do you save-state the VM or fully shut it down before switching host OS's? Is the VM's disk file in the same folder as the .vbox file?

Also, do you make lots of configuration changes to the VM, like snapshots etc?
stylekilla
Posts: 4
Joined: 26. Aug 2021, 02:11

Re: Sharing Guest between dual booted Hosts

Post by stylekilla »

Hey cheers for responding. I'll answer the questions below:
Is the VM's .vbox file registered in both host OS's?
I assume by registered you mean it is set up as a VM inside the manager? If so, then yes.
If so, do you save-state the VM or fully shut it down before switching host OS's?
I fully shut them down, no save-states.
Is the VM's disk file in the same folder as the .vbox file?
Yes, everything is stored in the same folder. For further clarification, they are stored on an internal SSD (dedicated for VMs) that each host has access to.
Also, do you make lots of configuration changes to the VM, like snapshots etc?
No, I run the same configuration on both hosts, no changes, no snapshots. The only thing that changes between the two systems that I can think of is the host audio driver (PulseAudio on linux, and then whatever the windows one is - and this setting changes automatically).

So it's not just me, it is strange right?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Sharing Guest between dual booted Hosts

Post by scottgus1 »

Seems that your setup and usage are compatible with an idea I have. If you do not use Virtualbox encryption, I would try this in one host:

0. Get the VM running in Linux.
1. detach the disk file from the Linux host VM.
2. unregister the Linux host VM while keeping all the files.
3. make a copy of the .vbox file in a new folder in Linux.
4. register the copy of the .vbox file with the Linux host.
5. attach the former disk file, which is still in the old folder, to the new VM.
6. In the Windows host, re-attach the disk file to the Windows host VM again.

Now you will have two separate copies of the VM pointing at the one disk file. Theoretically, if you make no further changes to the VM's configuration, each VM can point at its own host hardware while running the VM's disk file.

A good confirmed backup of the whole original VM folder would be a wise thing in case something goes wrong
stylekilla
Posts: 4
Joined: 26. Aug 2021, 02:11

Re: Sharing Guest between dual booted Hosts

Post by stylekilla »

Hi guys.

Scott, I've tried your solution (very clear instructions by the way) and it seems to be working nicely in both hosts.
Cheers for that, it's a neat little trick.

Is there anything I should be cautious of in this kind of setup?
For example, I'm not sure of what would happen if I changed something in one config but not the other, could the disk file get corrupted?
Not that I plan to, but it's always nice to know the limitations.

Thanks again!

Edit: I just realised that maybe by "backup" you meant an on-going backup? Not just while I changed the configuration around.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Sharing Guest between dual booted Hosts

Post by scottgus1 »

Glad it worked, thanks for the feedback!
stylekilla wrote:what would happen if I changed something in one config but not the other
This would depend on the thing changed.

RAM levels, what the network is attached to, shared folders, things that control how the VM is connected to the host OS, should be OK.

Things that change the 'hardware' inside the VM: encryption, most of what's in System besides RAM, the kind of video card, network card or audio controller, etc, would cause hardware changes inside the VM and might mess up the VM's OS.

Anything related to snapshots and linked clones should not be used: these will be almost impossible to copy over correctly and will definitely mess up the VM on the other OS. Full clones will be OK, since the full clone becomes a separate VM.

Saved States are OK if you don't switch host OS's between runs of the VM. Saving State, then booting to the other host OS without running the VM, then switching back to run the VM should be OK. The saved state should only be run under the host OS where it was saved. Fully shut down the VM before switching host OS's if you want to run the VM under the other OS.

Fell free to pop on the forum any time and ask, "I have a VM where the disk file is pointed at by separate .vbox files in both host OS's on a dual-boot host: If I change X in one .vbox file without changing it in the other, will my VM get messed up?"
stylekilla wrote:an on-going backup?
I was only considering a backup just in case my instructions ended up being bad instead of good :D However, a backup routine is always a good idea if you want to preserve the VM. Three good backup routines would be:
  • Take a full disk image of the whole host with all the VMs fully shut down, not save-stated
  • Shutting down the VM and copying all its files
  • Run 3rd-party compatible backup software inside the running VM, sent to backup media outside the VM over the network
You may see some folks mention using a snapshot during an apparent backup routine. Don't believe it: snapshots are not backups, they're more like Windows System Restore Points. They make the VM more delicate, are not disk images, and cannot be used to restore the VM. Processes for backing up a running VM using snapshots leaves the "backup" in the state the VM would be in if you killed it unceremoniously, with dirty data and unsaved files. No backup routine can be relied on if you use snapshots in it.
stylekilla
Posts: 4
Joined: 26. Aug 2021, 02:11

Re: Sharing Guest between dual booted Hosts

Post by stylekilla »

Cheers for the help Scott, your wisdom is appreciated.

A quick update: This solution was working for a few days, then things completely stopped functioning (on the Linux side), but for another reason entirely.
For anyone else who reads this thread in the future, if you're having further troubles, I provide a few additional notes and learnings I've had throughout this process:

1. Turn off Windows Fast Boot (Power Options > Choose what the power buttons do > Un-tick the fastboot option).
Linux will not be able to mount drives with r/w permissions and will restrict the drive to read only. I believe a recent Windows update automatically turned this option on for me (very annoying).
2. In Linux, it's best to mount the drive automatically at startup using fstab and have it set the correct permissions and mounting location for the disk.

In my case, these items above meant that virtualbox couldn't write to the drive where the VDI was stored and thus the vbox would not boot.

Now everything works wonderfully again.
Post Reply