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).
Ah good ol ln. Is there nothing that symbolic links won’t fix? =)
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.