If you are the person having plenty of virtual machines on a single host Oracle VirtualBox, then the ‘VM Group’ feature will be very useful in managing them. It helps to arrange VMs in a particular group (in a single area) and work with them easily. This small guide shows how to create and manage VM groups in VirtualBox.
By creating VM Groups, we can apply specific commands to all VMs in that group by a single action. For example, you can power on all Linux VMs which are in the same group with just a single action.
We already published plenty of useful articles/guides about Oracle VirtualBox here.
Let’s find out how to create, manage, and delete VM Groups with the below example. Let’s say I want to create a VM group for certain Windows Servers on my host.
How to Create a VM group in Oracle VirtualBox
You can create a VM group in several ways by VirtualBox manager GUI or command prompt, but below is the easiest way. Though the below screenshots were taken on the older version, the same steps remain the same for the latest VirtualBox versions.
1) Select the VMs (by pressing and holding the Ctrl key) and right-click, choose Group as shown below.
2) You can add more virtual machines to a group by drag and drop later.
To Rename a group, Right-click on the group title bar and select Rename Group option, pressing the F2 key also works.
Create VM group in command prompt
Group membership is an attribute of the VM, so you can modify the VM to be part of a group. For example, to add a virtual machine called “Ubuntu” into the group “TestGroup”, execute the below command:
From the command line:
VBoxManage modifyvm "Ubuntu" --groups "/TestGroup"
Also, a virtual machine can be part of more than one group.
For example, the same Windows server we used in this case can be part of another VM group name, let’s say ‘Cluster Project’ group.
You have to press the ‘Alt’ key while dragging a virtual machine in-between VM groups to keep it in more than one group.
Here is the command to keep a particular VM in more than one VM group.
VBoxManage modifyvm "Ubuntu" --groups "/TestGroup","/ProjectX","/ProjectY"
You can navigate and view only the virtual machines in a particular VM group easily by pressing the right/left arrow at top of a VM group.
Then press the left arrow (Exit group) button to go back to the home page of virtual machines.
Main Purpose of VM Groups, Why to Have it?
Keeping similar virtual machines based on the purpose in a group is helpful to have an organized view. Also, you can do several tasks to the VM group at one time which will be applicable for all virtual machines in that group.
Here are the tasks that can be done at the VM group level,
Start (starts from any state like boot or resume), Power on the VMs in headless mode (hold Shift while starting), Pause, Reset, Close, Save state, Send Shutdown signal, Power off, Discard saved state, Show in the file system and Sort. These all actions can be done at the VM group level.
In the below example, I can start all Windows servers (in the group) by clicking Start.
How to Delete a VM Group or Remove a VM from a Group
If you want to remove a group (which is having virtual machines), Right-click on the group and select ‘Ungroup’ as shown below.
Ungrouping will place the VMs in the normal place.
If you like to remove a particular virtual machine from a group, you just need to drag and drop it to the empty place in the console. DO NOT SELECT REMOVE OPTION in the Virtual machine which is similar to removing/deleting a virtual machine from the VirtualBox host.
You can use the following command to remove a VM from a group.
VBoxManage modifyvm "Ubuntu" --groups ""
The above command changes the attributes of VM to empty group name, like no group.