If you run multiple operating systems on your Mac in virtual machines, then you likely use either Virtual Box, VMWare Fusion, or Parallels Desktop. For the most part, when you set up a VM on your Mac with any of these solutions, it will run as a window that shows you the graphical view of the virtualized OS. However, if you use your VMs for servers instead of running desktop applications, then you can use a small trick to run them in the background, and thereby save both a little processing power and some desktop clutter.
By default when running VM software will show some virtual machine list window, where you can select your desired VM and launch or configure it. However, when run from these interfaces, a display view to the virtual machine will show. Unfortunately, closing this view will generally suspend or shut down the VM.
For the most part, you might not be too bothered by having a virtual machine window open, since you can hide or minimize it to keep it out of the way; however, if you want a more seamless and “headless” approach for running your VM’s in the background, then the following approaches will do the trick.
- Quit Parallels Desktop, if it’s open
- Open the Terminal utility
- Get a list of the current configured VMs:
prlctl list -a
- Note the name of the VM you want to start, and then start it:
prlctl start "VM NAME"
- Open the VirtualBox VM list
- Hold the Shift key when clicking Start for your VM
- Open the Terminal and make an alias to the “vmrun” program (assuming Fusion is installed in the Applications folder):
alias vmrun=/Applications/VMware\ Fusion.app/Contents/Library/vmrun
- Start the vm without the graphical interface:
vmrun -T fusion start "/path/to/vm.vmx" nogui
Note that making a command alias as shown here is just a temporary way to point to the hidden “vmrun” program. There are more permanent solutions you can use, including soft links, and embedding this alias command in your shell profile.
After running these commands, you will see an indication in the Terminal that the VM is starting, and once done you should be dropped back to the command prompt. From here, you should be able to access all of the services you have configured for your VM, including things like database access, web services, file sharing, and even screen sharing for accessing your VM’s GUI if needed, without any requirement to keep it persistent in an application window.
Note that for each of these commands, as with many command-line tools, running them without any arguments will give you a quick help output that will show you a synopsis of the command’s options. While I have outlined options for starting your VMs in headless modes, you can use the additional options to do things like pause and resume your VMs, restart them, and otherwise manage them while keeping them tucked behind the scenes.