Note:
- This tutorial is available in an Oracle-provided free lab environment.
- It uses example values for Oracle Cloud Infrastructure credentials, tenancy, and compartments. When completing your lab, substitute these values with ones specific to your cloud environment.
Use Oracle VM VirtualBox on Oracle Cloud Infrastructure Instances
Introduction
Oracle VM VirtualBox allows the simple and fast creation of virtual machines (VM) supporting a wide variety of operating systems. VirtualBox can be installed and run on various platforms, from a standalone laptop to a cloud instance. This hands on lab guides you through installing VirtualBox and its extension pack on an Oracle Linux cloud instance. It steps you through creating a new virtual machine using VirtualBox installed on the cloud instance, and installing the Guest Additions to the new VM.
You will practice implementing nested virtualization in VirtualBox to support the creation of virtual machines on the cloud instance. You will install Guest Additions to a VM which will provide closer integration between host and guest and improve the interactive performance of the guest system.
You can read more detailed information about Oracle VM VirtualBox at this documentation link: Oracle VM VirtualBox Documentation
There are free videos available demonstrating more functions of Oracle VM VirtualBox as well as its integration with Oracle Cloud Infrastructure, you can find a link to them in the For More Information section at the end of this lab.
Objectives
In this lab, you will learn to:
- Create a SSH tunnel to an Oracle Linux Server instance
- Connect to the cloud instance Server GUI Desktop with VNC
- Install Oracle VM VirtualBox to an Oracle Linux cloud instance
- Install the VirtualBox Expansion Pack
- Use VirtualBox to create a new Oracle Linux virtual machine
- Install VirtualBox Guest Additions to a Virtual Machine
Prerequisites
Basic experience of working with Oracle Linux command line and its desktop graphical user interface.
Setup Lab Environment
A new Oracle Linux 8 instance called ol-vbox is automatically provisioned and started when this lab is launched. Virtualization support has been enabled in this instance.
Oracle VM VirtualBox and Tiger VNC software is automatically installed to the instance when this lab is launched.
To support an SSH connection to the new instance terminal, public and private authentication keys have already been created and set to the instance and cloud console.
Create a SSH Tunnel to an Oracle Linux Server
Connect to the Lab Desktop GUI
Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions. As this lab will not be using Oracle Cloud Infrastructure console, you do not not need the information regarding Logging into the Oracle Cloud Console.
Information: The free lab environment deploys a running Oracle Linux cloud instance with Oracle VM VirtualBox and Tiger VNC installed. The deployment takes approximately 15-20 minutes to finish after launch. Therefore, you might want to step away while this runs and promptly return to complete the lab.
To access the desktop GUI of the Oracle Linux cloud instance server running VirtualBox, you will make a VNC connection from the Luna desktop to the cloud instance. Before making the VNC connection, an SSH tunnel is established to support the VNC connection.
Establish an SSH Tunnel
To support the VNC connection to the cloud instance desktop GUI, create an SSH tunnel to the cloud instance.
You can find the IP address of the cloud instance on the Resources tab on your Luna Lab web page.
-
Right click on your Luna desktop, select Open Terminal Here and configure the SSH tunnel.
ssh -L 5914:localhost:5901 oracle@<cloud instance ip address>
-
Input
yes
to continue connecting when prompted.Example Output:
[luna.user@lunabox Desktop]$ ssh -L 5914:localhost:5901 oracle@132.226.197.40 The authenticity of host '132.226.197.40 (132.226.197.40)' can't be established. ECDSA key fingerprint is SHA256:Nv0aGNEbH9AWywuAmWT8JSl4dTy+HSiII6DmjCaqoVE. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '132.226.197.40' (ECDSA) to the list of known hosts. Activate the web console with: systemctl enable --now cockpit.socket [oracle@ol-vbox ~]$
Connect to the Instance Server GUI Desktop with VNC
Use TigerVNC to connect to the cloud instance desktop GUI.
-
Right click on desktop, navigate to Applications - Internet - TigerVNC Viewer.
-
Connect to
localhost:5914
. -
For VNC Authentication use the password
oracle
.Note: If you are not prompted for the authentication password or the connection fails, check you have correctly used the SSH tunnel command, especially the port parameters
5914:localhost:5901
. -
If you are presented with an Authentication Required dialog to refresh the system repositories. Use the password
oracle
and click Authenticate. If you are not presented with this dialog, simply move on to the next step. -
As this is the first time logging into the server desktop, you will be presented with some default welcome screens. Keep the default language presented and click Next.
-
If the default keyboard displayed is not correct for your keyboard layout, change the layout by clicking on the three dots and type in the name of your preferred region. Select your region and click Next to continue. Ensure the region you added is selected by clicking on it before closing the window.
Note: If you choose a different keyboard layout, make sure the keys layout is correct for your keyboard. If not, you may have problems using the correct command line characters later when using the terminal in your instance or new virtual machine.
-
Click the slider to turn off location services, then click Next.
-
Do not connect any online accounts, click Skip to continue.
-
Click Start Using Oracle Linux Server.
-
Close the Getting Started window, you can browse through this and watch the videos if you wish, but it is not part of this hands on exercise.
OPTIONAL: Verify your Keyboard Layout is Correct
The default keyboard layout set to your prebuilt cloud instance is English (US). If you accepted the default keyboard, or changed to your preferred region, verify the correct keyboard layout is set. It is important to ensure the correct key characters are available in the various desktop and virtual machine environments used in this lab. Here are the steps again to set the keyboard region used.
-
Click on the Activities menu, select the multiple dots Show Applications icon. Click on Settings.
-
Select Region and Language.
Ensure the Region you require is selected. If not, then simply click on the region to select it.
If you need to add a region, lick the + button. Find and select the regional layout you want to use, then click Add.
Select the new layout and click the up arrow ^ to move it up to the top of the list. Ensure its highlighted.
Close the Settings window.
This sets the keyboard layout for your host cloud instance environment. Later you will also need to ensure the same layout is used in virtual machines used or built.
Install VirtualBox to the Oracle Linux Cloud Instance
For Oracle Linux systems, install the required packages to support the VirtualBox installation and the building of the driver modules to be loaded into the kernel.
Note: For Windows systems these packages are not needed to install VirtualBox, but are installed into guest virtual machines to support Guest Additions features in the VMs.
Install Supporting Packages
-
Click on Activities menu, select the Terminal icon.
-
Install the essential Linux packages to support VirtualBox.
sudo dnf install -y kernel-uek-devel-$(uname -r) gcc make perl
Note:
uname -r
will ensure that the matching development packages for the currently active uek kernel get installed. This may take a few minutes to complete.
OPTIONAL: Install Dynamic Kernel Module Support (DKMS) .
Installing the dkms
package ensures modules are automatically recompiled if the Linux kernel on the VirtualBox host system is upgraded. Otherwise you will need to run /usr/sbin/vboxsetup
after any host system kernel is updated. dkms
is not required for VirtualBox installation, but is a valuable package for supporting kernel updates to the host system.
-
Enable the repository.
sudo dnf config-manager --set-enable ol8_developer_EPEL
-
Verify the repository is installed.
sudo dnf repolist
Example Output:
ol8_developer_EPEL Oracle Linux 8 EPEL Packages for Development (x86_64)
-
Install the
dkms
package.sudo dnf install -y dkms
Install VirtualBox
-
Click on Activities menu, select the Firefox browser icon.
-
Go to http://www.virtualbox.org.
-
Click the Downloads link on the left side menu.
-
In the main window, under VirtualBox 7.0.x platform packages, click Linux distributions.
Note: The version of VirtualBox 7.0 you see may be different from the version in the image. VirtualBox is often updated, use the version presented to you on the Downloads page.
-
The instance you are using with desktop GUI is running Oracle Linux 8. Under VirtualBox 7.0.4 for Linux, right-click the link for Oracle Linux 8 and select Copy Link.
-
Return to your Terminal application. Hint: Click the Activities menu to see all open applications.
-
In the terminal, install the VirtualBox package using the
dnf install
command. Install using link copied in the previous step.sudo dnf install -y https://download.virtualbox.org/virtualbox/7.0.4/VirtualBox-7.0-7.0.4_154605_el8-1.x86_64.rpm
Note: The https link you copy may be different if the VirtualBox version is different to that shown here.
When the installation completes, validate that VirtualBox was successful installed.
-
Verify the kernel modules are loaded.
sudo lsmod | grep vbox
Example Output:
vboxnetadp 28672 0 vboxnetflt 28672 0 vboxdrv 536576 2 vboxnetadp,vboxnetflt
-
Click on the Activities menu, select the multiple dots Show Applications icon.
-
Click the Oracle VM VirtualBox application to open it.
Install the VirtualBox Expansion Pack
Return to the browser showing the VirtualBox page.
-
Click the Downloads link on the left side menu.
-
On the Download VirtualBox page, scroll down to the VirtualBox 7.0.x Oracle VM VirtualBox Extension Pack section. Click the link All supported platforms.
-
This downloads the extension pack in the browser and saves the file to the Downloads directory.
-
Return to the VirtualBox application.
-
In the VirtualBox window, close the notifications window showing Can’t enumerate USB devices….
-
Click the three dots icon in the Tools menu and select Extensions.
-
Click the Install button to begin installing the Extension Pack.
-
If not already selected, select the Extension Pack file and click Open.
-
Click Install in the confirmation dialog.
-
In the License dialog, scroll the text to the bottom and click I Agree.
-
In the Authentication Required dialog, input the password
oracle
to give elevated permissions to perform the install and click Authenticate. -
The Extension Pack is now installed.
Use VirtualBox to Create a New Oracle Linux Virtual Machine
Create the Virtual Machine
-
In the open VirtualBox application, Click the Tools menu and select Welcome.
-
Click New to create a new VM.
-
Click the Expert Mode button.
Note: For convenience, Expert Mode allows for the initial configuration of the new VM in a single page multi section dialog. It also provides additional configuration options, not available in the Guided Mode. However, after creating the VM, all parameters options are available for editing.
-
Under Name and Operating System, insert the name
ol8-6new
name for the new VM. You can choose your own name if you prefer. -
Click the ISO Image dropdown, select Other.
-
Select the preloaded ISO file listed in the /home/oracle directory. Click the Open button to select it for use.
Note: You can also download Oracle linux ISO files from yum.oracle.com and the Oracle Software Delivery Cloud edelivery.oracle.com.
-
Tick the box for Skip Unattended Installation. This prevents VirtualBox from automatically performing the full installation of the operating system.
-
Expand the Hardware section by clicking on the arrow beside the title.
Set the Base Memory to a minimum of 4096 MB, use the slider or input the value into the field to make the change. Set Processors to 2 with the slider or input field. These are minimum values reccommended for a new Oracle linux VM.
-
Expand the Hard Disk section.
Set the size of the hard drive to be used with the new VM, here you can leave the default of 20GB. If you want to use a different value make sure you select a minimum to support the type of Oracle Linux installation you will select later.
Leave the Pre-allocate Full Size check box unselected. This will allow the VM to use only the space it needs, up to the 20GB configured size.
Note: The lab has been configured with approximately 100GB of available space for use for new VMs. If you create more than one VM remember to take a note of what space is subsequently available for new VMs.
If you want to select a different hard disk type to be created, for example VMDK or QCOW type, click on the dropdown in the Hard Disk File Type and Variant section.
-
Click Finish to create the VM configuration.
You are returned to the VM parameters screen.
Enable Nested Virtualization
Before starting the VM, nested virtualization needs to be enabled for the new VM.
-
In the VM parameters, click on System to open the system settings for the VM.
-
Select the Processor tab. Tick the box for Enable Nested VT-x/AMD-V. Click the OK button to accept the setting.
Launch the Virtual Machine and Install the OS
-
Click Start to launch the VM and start the operating system installation.
-
At the Linux launch menu, press the up arrow to select Install Oracle Linux 8.6.0 and press the Return key to begin the installation.
Note: When you click into the new VM window you are presented with a window informing that the mouse will be captured in the window. Tick the box Do not show this message again and click Capture. Any time after this when the mouse pointer is captured you will not be reminded of this. To get mouse control back outside of the VM window, press the Right Ctrl button on your keyboard.
Note: When your mouse is captured in the VM it tracks according to the resolution of the VM. This can be different to your Luna desktop environment and results in two mouse pointers displayed at times, with each having seperate mouse tracking on screen. Ensure you are moving and clicking with the correct pointer inside the VM window.
-
Soon you are presented with the Oracle Linux graphical installation utility. Click the Delete finished notifications button to close the notification slider window.
-
Take the default language setting and select Continue.
Note: On a macOS machine it is recommended to reassign the key to recover mouse control outside of the VM window. You can set this in the main VirtualBox application window. Go to File - Preferences - Input - Virtual Machine tab - Host Key Combination.
-
OPTIONAL: Set your keyboard layout. If your keyboard matches the default shown, then it is not necessary to set the correct layout. However it is important to ensure the correct keyboard characters are used in the VM.
Under the LOCALIZATION section, click Keyboard.
Click the + button to add a new layout. In the ADD A KEYBOARD LAYOUT window start typing the name of the region you want to use. Select the region and click Add.
Move the new region to the top of the list, select the region name and click the up arrow ^ button to move it to the top. Ensure the correct region you want is highlighted, and click Done.
-
Under the SYSTEM section, click Installation Destination.
For Device Selection, Click the ATA VBOX HARDDISK entry two times, then click Done.
-
Under the SYSTEM section, select Network & Host Name.
Click the slider button to enable the Ethernet (enp0s3) connection to ON, and click Done.
-
Under the SOFTWARE section, select Software Selection.
For this installation select Server with GUI if it is not already selected, and then click Done.
-
Under the USER SETTINGS section, select Root Password.
Input the password
oracle
into the Root Password and Confirm fields. Or choose your own password for the root account.Note: The password
oracle
is a weak password, if you use a weak password you need to click Done two times to have it accepted. -
Click Begin Installation to install the operating system to the VM.
The install will take a few minutes.
Note: The installation can take approximately 20 minutes to complete. Feel free to leave your lab running and step away until the installation is completed.
-
When the installation is complete, click Reboot System to restart the VM and launch the new operating system.
After the VM has rebooted, on the INITIAL SETUP screen, in the section LICENSING, click License Information.
Tick the box for I accept the license agreement and then click Done.
-
Click FINISH CONFIGURATION.
The installation will take a few minutes to complete.
The operating system now presents you the desktop GUI, and the Welcome screen.
-
Click Next on the Welcome screen.
-
Click the slider to turn off the Location Services and then Next.
-
Click Skip to continue without connecting online accounts.
-
Input a name into the Full Name field, the same name is input into the Username field, then click Next.
-
Set a password, use
oracle
, if you pick your own make sure to take note of it. Click Next. -
Click Start Using Oracle Linux Server to finish the initial setup.
-
Close the Getting Started window.
Install VirtualBox Guest Additions to the New Virtual Machine
Prepare VM for Guest Additions
In this new virtual machine you have installed the Oracle Linux Server with GUI desktop.
To support additional useful VirtualBox features, install the optional VirtualBox Guest Additions to your VM.
Note: The copy and paste function does not work with the new virtual machine until Guest Additions are installed and that function is enabled from the Devices menu. You will need to manually type in the following commands. Take care to accurately type the commands.
On your VM desktop click on Activities menu, click the Terminal icon to open a terminal on your VM.
Note: You may be presented with a notification to install OS updates. This can be dismissed or ignored, as you will do this manually.
OPTIONAL: Updating the operating system is not required to install the Guest Additions, but is recommended.
-
Update to the latest software. This will take a few minutes to complete.
sudo dnf update -y
Give the password
oracle
, or the one you selected for the name you created in the startup screen. The update begins and will take a few minutes to complete.Note: If the desktop locks due to inactivity, drag the mouse from the bottom of the desktop upwards to unlock. Input the password to access the desktop again.
-
When the update completes, reboot the VM.
sudo reboot
When the reboot is complete, log back in by clicking on your username button and giving the password you set.
Install the required supporting packages needed to support the installation of Guest Additions features.
-
On your VM desktop click on Activities menu, click the Terminal icon to open a terminal on your VM.
-
Install the packages with the
dnf install
command. Give your password to run the command at elevated privileges for your user.sudo dnf install -y kernel-uek-devel-$(uname -r) gcc make perl
OPTIONAL: Install Dynamic Kernel Module Support (DKMS) .
With dkms
installed, modules are automatically recompiled if the Linux kernel on the VirtualBox host system is upgraded. Otherwise you will need to run /usr/sbin/vboxsetup
after any host system kernel is updated. dkms
is not required to install VirtualBox Guest Additions software, but is a valuable package for supporting kernel updates to the host system.
-
Install the ol8_developer_EPEL repository.
sudo dnf install -y oracle-epel-release-el8
-
Verify the repoistory is installed and enabled.
sudo dnf repolist all
Verify the two EPEL repos
ol8_developer_EPEL
ol8_developer_EPEL_modular
are enabled. -
Install the
dkms
package.sudo dnf install -y dkms
Install Guest Additions
Guest Additions are designed to be installed inside a virtual machine after the guest operating system has been installed. They consist of device drivers and system applications that optimize the guest operating system for better performance and usability.
-
With the supporting packages installed press Right Crtl on your keyboard to get mouse control outside of the VM window. Click on the Devices menu at the top, then Insert Guest Additions CD image….
Note: For macOS computers, use the key combination you set to exit capture from the VM. You can set this in the main VirtualBox application window. Go to File menu - Preferences - Input - Virtual Machine tab - Host Key Combination.
-
After a few seconds the install dialog opens, Click Run, then enter your user password and click Authenticate to start the Guest Additions installation for your VM.
-
This opens a terminal on your desktop and displays the installation stages.
-
After a few minutes, the install completes and you can press Return to close the installation dialog.
With the Guest Additions installed, mouse integration is now easier, and you do not need to use the Right Ctrl key to exit the VM window. You can also drag the border of your VM and the VM desktop will automatically resize to the new window size.
From the VM Devices menu you have the option to enable and use shared folders and shared clipboard with your VM. After enabling these features, restart the VM to start using them.
Congratulations!
You have successfully completed this lab.
To end this session, click the End Session button in the toolbar.
For More Information
See other related resources:
-
Video: Integrate VirtualBox 7.0 with Oracle Cloud Infrastructure
-
YouTube Playlist: Oracle VM VirtualBox playlist
-
Document: Oracle VM VirtualBox Documentation
-
Luna Labs: Linux OS and Virualization Engineering Labs
-
Training Track: Oracle VM VirtualBox Training Track
-
Training Track: Linux on Oracle Cloud Infrastructure Training Track
-
Document: Oracle Linux Documentation
More Learning Resources
Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.
For product documentation, visit Oracle Help Center.
Use Oracle VM VirtualBox on Oracle Cloud Infrastructure Instances
F75616-01
December 2022
Copyright © 2022, Oracle and/or its affiliates.