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:
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.
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.