NB This guide has been left for reference, but generally we now suggest that if you require to use Nested Virtualisation that this is done using KVM inside a Standalone machine and the use of Virt Manager.
A step by step guide will shortly be written to explain how this is done.
How to set-up Virtual Machine Manager in an LXC container - Deprecated
Install Virt Machine Manager on Host
Ubuntu 20.04 onwards (Ubuntu 22.04 is preferred)
-
Create a standalone machine, and for best results we suggest that Ubuntu 22.04 is used. Ensure that the 'Convert to LXC' is ticked to allow nested virtualisation, eg guest machines within this host Desktop. This means that the machine is actually ran as a LXC container rather than a KVM machine. Please note that this option is only allowed for users who are Super Administrators. If you require nested virtualisation and do not have super administration privileges, please contact DaDesktop Tech Support who can provide the machine set up in this manner for Trainers.
-
Install Virtual Machine Manager, ie
sudo apt-get install virt-manager
No kernel module re-compilation is required (required for VirtualBox) as this is a fully open source application that works with any recent kernel.
-
Reboot the Ubuntu machine host. Please note it is essential to reboot the host machine to ensure that the libvirt virtualisation is fully set up and running. Test the QEMU - libvirt connection
-
Create Guest VMs as required. IP addresses allocated for guest VM's allow pinging between guest machines without any additional work.
How to set-up VirtualBox in an LXC container ?Deprecated
IMPORTANT
- If you want to run Virtualbox in a LXC container, you need to ensure that all running kvms on the host are stopped first
- If Virtualbox has been started in a LXC container, any running kvm machines will fail
Quickguide
- Install virtualbox-dkms on Host:
Up-to-date (from Ubuntu 21.04): - Install Virtualbox on Container
- FAQ
Install virtualbox-dkms on Host:
Up-to-date (from Ubuntu 21.04):
Ubuntu 21.04 onwards (Kernel 5.11) cannot install virtualbox-dkms_6.1.14-dfsg ..
So we need to upgrade the Virtualbox on the dd nodes.
curl -sL -o /tmp/virtualbox-dkms_6.1.38-dfsg-3~ubuntu1.22.04.1_amd64.deb
http://archive.ubuntu.com/ubuntu/pool/multiverse/v/virtualbox/virtualbox...
&& sudo dpkg -i /tmp/virtualbox-dkms_6.1.38-dfsg-3~ubuntu1.22.04.1_amd64.deb || sudo apt --fix-broken install -ysudo modprobe vboxdrv
sudo modprobe vboxnetadp
sudo modprobe vboxnetflt
Install VirtualBox on Container
You need to install the same version of Virtualbox as on the host.
https://www.virtualbox.org/wiki/Download_Old_Builds_6_1
FAQ
-
How can I create a network in Virtualbox Host Network Manager? : Run this command in terminal before opening Host Network Manager:
nmcli conn add type bridge con-name vboxnet0 ifname vboxnet0
-
If multiple network cards are enabled for the virtual machine in Virtualbox settings, it appears in the GUI that only one can obtain the IP address. To get around this issue, edit netplan, and add the 2nd network in the config file.