LinuxMint 19: Install VirtualBox for virtualization

This article will describe installing VirtualBox.

1 Install VirtualBox

Install virtualbox package. virtualbox-ext-pack needs license agreement.

$ cat <<EOF | sudo debconf-set-selections
virtualbox-ext-pack virtualbox-ext-pack/license boolean true
EOF
$ sudo apt install -y -o 'apt::install-recommends=true' \
  virtualbox virtualbox-guest-additions-iso virtualbox-ext-pack

2 Run VirtualBox

Run virtualbox command.

$ virtualbox

0001_VirtualBox.png

3 Access to guest machine from local network machine with bridge adapter

While libvirt+KVM needs bridge interface, VirtualBox allows physical ethernet device or bridge interface.

For example, eth0 is ethernet device and br0 is bridge interface which is bridged to eth0. libvirt+KVM needs br0, and VirtualBox allows both eth0 and br0.

But you need to set "Adapter Type" to "Paravirtualized Network (virtio-net)" which is paravirt driver. If you does not use it, local network machines cannot access to virtual machine (Connection is established but stalled immediately).

0002_BridgeAdapter.png

4 Run VirtualBox with VBoxManage

VBoxManage can be used via CUI. It is easy to be scripted.

Clone virtual machine.

$ VBoxManage clonevm <OriginalVMName> --register --mode machine \
             --name <ClonedVMName>

Get MAC address of virtual machine.

$ VBoxManage showvminfo --machinereadable vbx-ubuntu-1804-test | \
              grep '^macaddress[0-9]*'
macaddress1="080027A0CEDB"

Start virtual machine. –type headless option can start virtual machine without displaying console window.

$ VBoxManage startvm --type headless <VMName>

Shutdown virtual machine with ACPI (Some OS needs ACPI settings for shutdown).

$ VBoxManage controlvm <VMName> acpipowerbutton

Delete virtual machine. Stop virtual machine with shutdown (power off) before deleting because machine must be stopped for deleting virtual machine,

$ VBoxManage controlvm <VMName> shutdown
$ VBoxManage unregistervm --delete <VMName>