You might be familiar with VirtualBox, a free and open-source software package for running virtual PCs on a host machine. It was developed by Oracle and can be installed on Windows, Macintosh, Linux, and Solaris hosts.
Supported guest operating systems, those running virtually inside the “box,” include DOS, just about every Windows version since NT 4.0, major Linux kernel versions, Solaris, and OpenSolaris, OS/2, and OpenBSD. Others probably work too. Setting up VirtualBox 5.0 is a fairly simple process, and is largely unchanged from earlier versions that have been covered here before.
There remains one glaring omission in this otherwise excellent Hypervisor product, however. To spot it, just check chapter 9, section 24 of its online manual:
Starting with VirtualBox 4.2.0 it is possible to start VMs automatically during system boot on Linux, Solaris and Mac OS X for all users.
That’s right, there’s no option to automatically launch your virtual machines on a Windows host. Server reboots? Sorry, your virtual machines are still turned off. Better go log in and boot them all up again.
Luckily, there are a couple third-party solutions to this problem. This article will cover VBoxVmService, a trusty helper I’ve used for the past couple years in a live Windows server environment.
Before doing anything with VBoxVmService, set up all your virtual machines the way you like them. Oracle’s VirtualBox Manual has pretty good instructions (if distressingly few screenshots). Modifying any one VM after VBoxVmService is running is a tiny bit of a hassle, so choose settings that won’t need to be changed often.
All set? Okay then.
Head on over to VBoxVmService’s Sourceforge page and click the main image to download the EXE installer. Run the executable for a very standard wizard, which places all its files in C:\vms by default. Head to that directory to find a nice little list of files.
We’re mostly concerned with the INI file, since that’s where all our settings go. Open it up in Notepad or your preferred text editor to see its initial state.
The VBOX_USER_HOME variable is probably fine as-is if you installed VirtualBox and VBoxVmService with their default settings. The path is not the same (necessarily) as the Default Machine Folder set within the Preferences of Oracle VM VirtualBox Manager.
RunWebService controls whether or not to start VirtualBox’s HTTP web service automatically, so only change that to “yes” if you need it. PauseShutdown allows extra time, in milliseconds, for VMs to gracefully shut down if the host machine is shut down.
The first thing to do is to replace the VmName with the name of your VM(s). If you only have one, remove everything from [Vm1] on. If you have more than two, add more sections with the same format starting with [Vm2], then [Vm3], etc.
Depending on your user permissions, you might also need to add two lines granting the service access to the VBOX_USER_HOME directory. Put them in the [Settings] section:
Don’t worry, that cleartext password is only there very briefly. You can delete those lines immediately after installing the service.
Save VBoxVmService.ini and then open a command prompt as Administrator. Run the following command, which installs the service:
You might get an error message:
Failed to create service VBoxVmService: The specified service already exists.
If so, just uninstall and reinstall the service:
In fact, any time you change something in VBoxVmService.ini, you’ll need to uninstall and reinstall the service. Adding or removing a VM, altering a VM’s AutoStart or ShutdownMethod, or tweaking the PauseShutdown time will require this procedure.
It’s not a bad idea to reboot either.
Back in the C:\vms folder, open VmServiceTray.exe to get a handy little icon near your clock that allows you to start and stop VBoxVmService, as well as any individual VMs. Create a shortcut and place it in the Startup folder to always have it on hand at boot.
You should be able to open the VirtualBox GUI with the service and VMs still running, but that wasn’t always the case. Versions 4.2 and 4.3 of the GUI wouldn’t open while VBoxVmService was started, so to make any modifications or add new VMs, the service (and therefore all running VMs) had to be stopped. If that issue pops up for you in version 5, take the following steps before opening the GUI:
You can now make changes to the VMs and open them interactively. When you’re done, close the VMs, close the VirtualBox GUI, and restart the service and each VM via the System Tray icon. Again, this shouldn’t be necessary with version 5, but it can’t hurt to be prepared.
Once started through VBoxVmService, your virtual machines can be used like any other remote machine - via Remote Desktop, VNC software, LogMeIn, TeamViewer, or whatever your preferred solution is.
Even though the Oracle VM VirtualBox Manager can be opened while your VMs are running under VBoxVmService, their state won’t be correctly reflected in that GUI. Try to start one that says it’s powered off and you’ll get a nasty error box containing multiple failures. You can stop the relevant VM through the System Tray icon if “ShutdownMethod” in your VBoxVmService.ini file is set to “acpipowerbutton”; if it’s “savestate”, though, you’re better off remoting into the VM and shutting it down properly.
For advice and hacks related to earlier versions, the VBoxVmService wiki is a good place to start. Happy virtualizing, and let us know your experiences!
As open source becomes the norm, open source intelligence tools are in demand. Here are a few that are already…
As businesses head to the cloud, will CapEx IT be a thing of the past? Or will there always be…
Don’t be this IT admin: Disaster hits and all you can say is, “I should have set up a database…
In protecting online privacy, the actions you take are far more important than any legal framework that could be put…
Cryptomining on the job behind the boss’s back is bad enough, but when the employees work in a nuclear power…
Cybersecurity experts recommend setting up a VPN to secure your data and privacy. But is purchasing a lifetime VPN subscription…