Creating and using VM Groups in VirtualBox
Posted
by Fat Bloke
on Oracle Blogs
See other posts from Oracle Blogs
or by Fat Bloke
Published on Wed, 21 Nov 2012 12:45:51 +0000
Indexed on
2012/11/21
17:08 UTC
Read the original article
Hit count: 520
/VirtualBox
With VirtualBox 4.2 we introduced the Groups feature which allows you to organize and manage your guest virtual machines collectively, rather than individually.
Groups are quite a powerful concept and there are a few nice features you may not have discovered yet, so here's a bit more information about groups, and how they can be used....
Creating a group
Groups are just ad hoc collections of virtual machines and there are several ways of creating a group:
- In the VirtualBox Manager GUI:
- Drag one VM onto another to create a group of those 2 VMs. You can then drag and drop more VMs into that group;
- Select multiple VMs (using Ctrl or Shift and click) then
- select the menu: Machine...Group; or
- press Cmd+U (Mac), or Ctrl+U(Windows); or
- right-click the multiple selection and choose Group, like this:
- From the command line:
- Group membership is an attribute of the vm so you can modify the vm to belong in a group. For example, to put the vm "Ubuntu" into the group "TestGroup" run this command:
VBoxManage modifyvm "Ubuntu" --groups "/TestGroup"
Deleting a Group
Groups can be deleted by removing a group attribute from all the VMs that constitute that group. To do this via the command-line the syntax is:
VBoxManage modifyvm "Ubuntu" --groups ""
In the VirtualBox Manager, this is more easily done by right-clicking on a group header and selecting "Ungroup", like this:
Multiple Groups
Now that we understand that Groups are just attributes of VMs, it can be seen that VMs can exist in multiple groups, for example, doing this:
VBoxManage modifyvm "Ubuntu" --groups "/TestGroup","/ProjectX","/ProjectY"
Results in:
Or via the VirtualBox Manager, you can drag VMs while pressing the Alt key (Mac) or Ctrl (other platforms).
Nested Groups
Just like you can drag VMs around in the VirtualBox Manager, you can also drag whole groups around. And dropping a group within a group creates a nested group.
Via the command-line, nested groups are specified using a path-like syntax, like this:
VBoxManage modifyvm "Ubuntu" --groups "/TestGroup/Linux"
...which creates a sub-group and puts the VM in it.
Navigating Groups
In the VirtualBox Manager, Groups can be collapsed and expanded by clicking on the carat to the left in the Group Header.
But you can also Enter and Leave groups too, either by using the right-arrow/left-arrow keys, or by clicking on the carat on the right hand side of the Group Header, like this:
.
..leading to a view of just the Group contents. You can Leave or return to the parent in the same way.
Don't worry if you are imprecise with your clicking, you can use a double click on the entire right half of the Group Header to Enter a group, and the left half to Leave a group. Double-clicking on the left half when you're at the top will roll-up or collapse the group.
Group Operations
The real power of Groups is not simply in arranging them prettily in the Manager. Rather it is about performing collective operations on them, once you have grouped them appropriately.
For example, let's say that you are working on a project (Project X) where you have a solution stack of:
- Database VM,
- Middleware/App VM, and
- a couple of client VMs which you use to test your app.
With VM Groups you can start the whole stack with one operation. Select the Group Header, and choose Start:
The full list of operations that may be performed on Groups are:
- Start
- Starts from any state (boot or resume)
- Start VMs in headless mode (hold Shift while starting)
- Pause
- Reset
- Close
- Save state
- Send Shutdown signal
- Poweroff
- Discard saved state
- Show in filesystem
- Sort
Conclusion
Hopefully we've shown that the introduction of VM Groups not only makes Oracle VM VirtualBox pretty, but pretty powerful too.
- FB
© Oracle Blogs or respective owner