Home > Mac administration, Mac OS X > Configuring a VirtualBox VM to be shared by multiple users on the same Mac

Configuring a VirtualBox VM to be shared by multiple users on the same Mac

I was asked at work to set a Fedora Linux VirtualBox virtual machine so that it could be accessed by multiple users on the same Mac. The VM had been already set up in /Users/Shared/VM_directory_name, so I reset the permissions on the VM so that it was read/write by a group that all the users were in and went off to the next issue.

Later that day, I get an update letting me know “Hey, we’re having permissions issues.” When I checked the VM, it looked like VirtualBox was giving ownership of the VM to the last user who had used the VM. Since that was locking out everyone else, this was a problem.

Fortunately, I was not the first person to run into this issue. In the event that someone else needs this, here’s one way to share a VirtualBox VM among multiple users on the same Mac.

1. Put the VM in a place that everyone can access. /Users/Shared is a good place.

2. Configure the VM to be the way you want it.

3. Go into Terminal and run the following commands:

cd ~/Library/VirtualBox

cp ~/Library/VirtualBox/VirtualBox.xml /path/to/shared/location/VirtualBox.xml

mv ~/Library/VirtualBox/VirtualBox.xml ~/Library/VirtualBox/VirtualBox.xml.bak

ln -s /path/to/shared/location/VirtualBox.xml

These commands will copy the configured VirtualBox.xml file to the shared location, back up the existing VirtualBox.xml in ~/Library/VirtualBox, and make a symbolic link to /path/to/shared/location/VirtualBox.xml in ~/Library/VirtualBox.

4. Adjust the permissions of /path/to/shared/location/VirtualBox.xml so that all of your users can read and write to this file.


Note: Because all accounts are linking to the same file, any changes to the VirtualBox configuration by one user will show up for everyone else as well. It also means that if the VirtualBox.xml configuration file stored in /path/to/shared/location is deleted or moved, it disappears for everyone.

Update 10-26-2011:

I also needed to set up a launchdaemon and script to make sure that the permissions stayed set, as VirtualBox on the Mac will reset the permissions of the VM to be exclusively owned by the account that last ran it. The permissions change happens when the VM is shutdown.

Here’s links to the script and the accompanying launchdaemon on my GitHub repo (make owner and group edits as appropriate).

  1. October 26, 2011 at 1:14 am

    Ah good ol ln. Is there nothing that symbolic links won’t fix? =)

  2. September 19, 2012 at 1:20 pm

    When I try to run a LaunchDaemon script to just open up permissions to the Vbox (being used in a computer lab) the logs error out saying that there is no such file or directory. When I push the command manually via ARD, it works fine. For the record, the filepath that is causing the problem is this: /Library/LabConfig/Users/setup/VirtualBox\ VMs/ENPS\ VM/ENPS\ VM.vbox
    So it’s a .vbox, not a .xml.
    I know this thread is almost a year old, but I’m sick/worried of pushing the command out manually via ARD in case it fails when someone needs it.

  3. Russ
    November 13, 2013 at 8:27 pm

    Use a hardlink, and the xml file will be much more persistent!

  4. mdelain
    December 29, 2013 at 10:46 pm

    Very interesting tutorial, thanx!
    Could you please detail a little more how to install the script + launcher?

  5. March 2, 2015 at 10:57 pm

    I found a site explaining that in Windows you could set an environment variable to tell VirtualBox where to look for VirtualBox.xml. (http://wp.shaibn.com/how-to-move-virtualboxs-entire-directory-including-virtualbox-xml-itself). That implies there is a feature in the software that we should be able to leverage to change the path and not have to deal with these dynamic links and startup daemons. ie. A much more elegant solution.

    Problem is, I’ve not been able to find it. I set an OS X environment variable (thusly: http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x) but VirtualBox doesn’t honor the setting. I also poked around the code inside the .app file but couldn’t find a spot to edit from “~/Library/VirtualBox” to “/Users/Shared”.

    What I think I’ll do instead of your links is to set up some Casper Suite policies. Specifically, on login I’ll have a script copy /Users/Shared/VirtualBox.xml down to ~/Library/VirtualBox. Then I’ll have another policy run either at logout or every 15 (or both) to copy it back up again. That way any changes by one user will get saved and the next user gets the most recent changes.

  6. March 2, 2015 at 11:00 pm

    PS: I also looked at the commandset in vboxmanage but saw no such setting therein. That was a bummer, as it’d have been the perfect place for it.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 204 other followers

%d bloggers like this: