Nested VM Setup — Oracle Linux 7.x

In this article, I would like to explain how the Kernel-based Virtual Machine (KVM) and the Oracle VirtualBox works within Oracle Linux 7.x as nested virtualization.

The following depicts the scenario as a diagram:

According to the above diagram, first create an instance on the OCI Environment (You can use any version of Oracle Linux ). Then, do the installation for the whole configuration.

Once the installation is done, you could connect via VNC Viewer or xRDP. You can open the Virtual Machine Manager on the Oracle Linux Environment, and create VMs on KVM (Kernel-based Virtual Machine).

Once you have installed the Oracle VirtualBox, you can open the application up and create VMs in that environment as well.

The above concept is called “Nested Virtualization”.

Please follow the below steps:

  1. Instance Creation on Oracle Cloud Infrastructure (OCI)

As a first step, you need to go to the Oracle Cloud Infrastructure(OCI).

Then click on the “Create Instance” button and add the public key as shown below.

2. The Public Key and Private Key Creation

For the public key and private key creation give the below command in your local machine.

Then ssh into it.

Once you have done the key creation, move onto the KVM installation!

3. KVM and Other Installations

Install the qemu package and it will provide a graphical interface to manage virtual machines.

Install the VNC packages.

Then copy the vncserver@.service file into the vncserver@:1.service file.

Replace <USER> with “opc” (username) in vncserver@:1.service.

Now, set the VNC password for the OPC user, defined in vncserver@:1.service.

Then, install firewalld on the Linux VM.

Configure the firewall to allow the VNC connection.

Configure VNC to autostart.

4. An Ingress Rule Creation

Now go back to OCI and go to the Virtual Cloud Network(VCN) section; then click on Security Lists and create an ingress rule with the below configuration.

Reboot the instance.

Then download the VNC viewer application to your local machine. [https://www.realvnc.com/en/connect/download/viewer/]

Open the application and enter the below details:

Put the password that you entered earlier [vnc password].

Now you have successfully connected to the Oracle Linux VM!

5. Setup an Ubuntu VM on KVM

Download an Ubuntu ISO file.

Then create a new VM on the virtual machine manager application.

Now you have successfully completed the setup of KVM on Oracle Linux!

6. Setup Xrdp

Install the Xrdp package using the yum command.

Once the package installation is done, start the Xrdp service.

Xrdp now should be listening on port 3389. Confirm it by using netstat.

Reboot the system and once again start the xRDP service.

Configure the firewall using the below commands.

Then, change the root password.

Go back to OCI VCN Security Lists and create an ingress rule as below:

Then check it with Remote Desktop Connection software. Put the public IP address under the PC name.

Ignore the security warning and connect with xRDP.

7. Oracle VirtualBox Installation

Open the terminal in your Oracle Linux VM.

Then check the Linux kernel version using the below command. (This step is required.)

Once you check the Linux kernel version, install the correct version of the Kernel with uname-r for the Oracle Virtualbox VM configuration. (This step is also required.)

Then exit the terminal and reboot the instance.

Install the VirtualBox using the below command.

Open the Oracle VirtualBox (I have already installed an ubuntu VM and configured it as below).

Click the “New” button and create a VM in the Oracle VirtualBox.

Once you have finished the creation, click “Start”.

The VM will be starting successfully!

Conclusion

Nested virtualization allows you to run a virtual machine (VM) inside another VM while still using hardware acceleration from the host. In this article, I have done the nested virtualization on the Oracle Cloud Infrastructure (OCI).

Thanks for reading, and let me know what you think!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store