How to create virtual machines with VirtualBox

Creating a new virtual machine

Step 1 : On the VirtualBox Manager, click on the New button at the top and a wizard that will help to create the virtual machine will pop up.

Step 2 : In the following screenshot, select the amount of memory. You may resize it after the installation. Click on the Next button.

Step 3 : Next, Select the Create a virtual hard drive now radio button. Click on the Create button. It will create a new virtual hard drive.

Step 4 : Select VDI as shown in the following screenshot and click on Next:

Step 5 : Select Dynamically allocated

Step 6 : Select the size of the disk for your VM. Click on the Create button.

Step 7 : If everything goes well, you can see the guest VM that you have created.

Starting the virtual machine

The VM can be started using various methods :

  • Double-click on the name of the guest VM in the VirtualBox Manager window
  • Select the name of the guest VM and click on the Start button at the top of the window
  • The VBoxManage command can also be used

Closing Virtual Machines

When you close the VM window, the following screen with three options appears:

  • Save the machine state : When you select this option, VirtualBox “freezes” the VM by saving its state completely to the hard disk. So, if you opt for this option and start your VM later, you will see that the VM starts from where you have left it; that means all the programs will be still open in the state that you have left it in and the guest VM resumes operation.
  • Send the shutdown signal : This option sends an ACPI shutdown signal to the guest VM. It is similar to pressing the power button on a physical computer.
  • Power off the machine : If you select this option, VirtualBox stops running the VM without saving its state. This is similar to pulling the power cable of a physical host. This option is not suggested because there might be a chance of data inconsistency and data loss as well.

Virtual machine groups

VM groups can be created with any of the following methods:

  • Create a group using the GUI option
  • Drag one VM on top of another VM
  • Select multiple VMs and select Group
  • The VBoxManage command can also be used

Virtual machine snapshots

Snapshots help to save the exact state of a VM for later use. At any point in time, you can easily revert to the previous required state even though you may have changed the guest VM. It’s similar to the saved state but many states can be preserved.

You can take a snapshot of a VM by selecting a machine in the VirtualBox Manager and then clicking on the Snapshots button on the top-right corner.

Taking, restoring, and deleting snapshots

You can take the snapshot of a guest VM that is either running, saved, or in the power-off state.

To take the snapshot, you either click on the Snapshots tab on the top-right corner of the VirtualBox Manager or right-click on the guest VM and select Take Snapshot.

To check the details of the snapshots, click on the VM. You can see the list of snapshots in the right-hand panel.

The Restore Snapshot option helps you to go forward or backward in time. By selecting this option you will lose the current state of the VM, but you will be able to restore the VM to the exact state when you have taken the snapshot. But if you don’t want to lose your current state, take a new snapshot of the current VM before restoring the VM.

The Delete Snapshot option helps to delete the snapshots of the guest VM, which in turn frees up the disk space. You can also delete the snapshots while the VM is in a running state.

Virtual machine clone

If you want to test some functionality in the currently running VM without interruption, or you want to make a backup, you can think of cloning. This feature helps to create the golden image or base image as well.

To make a clone, right-click on the guest VM and click on Clone….

If you select Reinitialize the MAC address of all network cards, every network card attached to the clone VM (Destination VM) gets a new MAC address assigned. If you don’t select it, the clone will have the same MAC address as the source VM. This will produce a MAC address collision in the network layer if you decide to use the source VM and cloned VM in the same network. However, its not an issue if you want your source VM and cloned VM in different networks. So, depending on the requirement either choose it or leave it as it is and click on Next.

Select the clone type.

Add Comment