Note:

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:

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.

  1. 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>
    
  2. 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.

  1. Right click on desktop, navigate to Applications - Internet - TigerVNC Viewer.

    open vnc

  2. Connect to localhost:5914.

    open vnc

  3. For VNC Authentication use the password oracle.

    open vnc

    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.

  4. 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.

    open vnc

  5. 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.

    open vnc

  6. 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.

    open vnc

    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.

  7. Click the slider to turn off location services, then click Next.

    open vnc

  8. Do not connect any online accounts, click Skip to continue.

    open vnc

  9. Click Start Using Oracle Linux Server.

    open vnc

  10. 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.

    open vnc

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.

  1. Click on the Activities menu, select the multiple dots Show Applications icon. Click on Settings.

    select modules

  2. Select Region and Language.

    select modules

    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

  1. Click on Activities menu, select the Terminal icon.

    open vnc

  2. 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.

  1. Enable the repository.

    sudo dnf config-manager --set-enable ol8_developer_EPEL
    
  2. Verify the repository is installed.

    sudo dnf repolist
    

    Example Output:

    ol8_developer_EPEL               Oracle Linux 8 EPEL Packages for Development (x86_64)
    
  3. Install the dkms package.

    sudo dnf install -y dkms
    

Install VirtualBox

  1. Click on Activities menu, select the Firefox browser icon.

    open vnc

  2. Go to http://www.virtualbox.org.

    open vnc

  3. Click the Downloads link on the left side menu.

    open vnc

  4. In the main window, under VirtualBox 7.0.x platform packages, click Linux distributions.

    open vnc

    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.

  5. 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.

    open vnc

  6. Return to your Terminal application. Hint: Click the Activities menu to see all open applications.

  7. 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.

  1. Verify the kernel modules are loaded.

    sudo lsmod | grep vbox
    

    Example Output:

    vboxnetadp             28672  0
    vboxnetflt             28672  0
    vboxdrv               536576  2 vboxnetadp,vboxnetflt
    
  2. Click on the Activities menu, select the multiple dots Show Applications icon.

    open vnc

  3. Click the Oracle VM VirtualBox application to open it.

    open vnc

Install the VirtualBox Expansion Pack

Return to the browser showing the VirtualBox page.

  1. Click the Downloads link on the left side menu.

    open vnc

  2. 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.

    open vnc

  3. This downloads the extension pack in the browser and saves the file to the Downloads directory.

    open vnc

  4. Return to the VirtualBox application.

  5. In the VirtualBox window, close the notifications window showing Can’t enumerate USB devices….

    open vnc

  6. Click the three dots icon in the Tools menu and select Extensions.

    open vnc

  7. Click the Install button to begin installing the Extension Pack.

    open vnc

  8. If not already selected, select the Extension Pack file and click Open.

    open vnc

  9. Click Install in the confirmation dialog.

    open vnc

  10. In the License dialog, scroll the text to the bottom and click I Agree.

    open vnc

  11. In the Authentication Required dialog, input the password oracle to give elevated permissions to perform the install and click Authenticate.

    open vnc

  12. The Extension Pack is now installed.

    open vnc

Use VirtualBox to Create a New Oracle Linux Virtual Machine

Create the Virtual Machine

  1. In the open VirtualBox application, Click the Tools menu and select Welcome.

    open vnc

  2. Click New to create a new VM.

    open vnc

  3. Click the Expert Mode button.

    open vnc

    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.

  4. Under Name and Operating System, insert the name ol8-6new name for the new VM. You can choose your own name if you prefer.

    open vnc

  5. Click the ISO Image dropdown, select Other.

    open vnc

  6. Select the preloaded ISO file listed in the /home/oracle directory. Click the Open button to select it for use.

    open vnc

    Note: You can also download Oracle linux ISO files from yum.oracle.com and the Oracle Software Delivery Cloud edelivery.oracle.com.

  7. Tick the box for Skip Unattended Installation. This prevents VirtualBox from automatically performing the full installation of the operating system.

    open vnc

  8. 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.

    open vnc

  9. 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.

    open vnc

    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.

  10. 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.

  1. In the VM parameters, click on System to open the system settings for the VM.

    open vnc

  2. Select the Processor tab. Tick the box for Enable Nested VT-x/AMD-V. Click the OK button to accept the setting.

    open vnc

Launch the Virtual Machine and Install the OS

  1. Click Start to launch the VM and start the operating system installation.

    open vnc

  2. 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.

    open vnc

    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.

  3. Soon you are presented with the Oracle Linux graphical installation utility. Click the Delete finished notifications button to close the notification slider window.

    open vnc

  4. Take the default language setting and select Continue.

    open vnc

    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.

  5. 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.

    open vnc

    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.

    open vnc

    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.

    open vnc

  6. Under the SYSTEM section, click Installation Destination.

    open vnc

    For Device Selection, Click the ATA VBOX HARDDISK entry two times, then click Done.

    open vnc

  7. Under the SYSTEM section, select Network & Host Name.

    Click the slider button to enable the Ethernet (enp0s3) connection to ON, and click Done.

    open vnc

  8. Under the SOFTWARE section, select Software Selection.

    For this installation select Server with GUI if it is not already selected, and then click Done.

    open vnc

  9. 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.

    open vnc

    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.

  10. Click Begin Installation to install the operating system to the VM.

    The install will take a few minutes.

    open vnc

    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.

  11. 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.

    open vnc

    Tick the box for I accept the license agreement and then click Done.

  12. Click FINISH CONFIGURATION.

    The installation will take a few minutes to complete.

    open vnc

The operating system now presents you the desktop GUI, and the Welcome screen.

  1. Click Next on the Welcome screen.

    open vnc

  2. Click the slider to turn off the Location Services and then Next.

    open vnc

  3. Click Skip to continue without connecting online accounts.

    open vnc

  4. Input a name into the Full Name field, the same name is input into the Username field, then click Next.

    open vnc

  5. Set a password, use oracle, if you pick your own make sure to take note of it. Click Next.

    open vnc

  6. Click Start Using Oracle Linux Server to finish the initial setup.

    open vnc

  7. 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.

  1. 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.

  2. 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.

  1. On your VM desktop click on Activities menu, click the Terminal icon to open a terminal on your VM.

  2. 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.

  1. Install the ol8_developer_EPEL repository.

    sudo dnf install -y oracle-epel-release-el8
    
  2. 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.

    select modules

  3. 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.

  1. 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….

    select modules

    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.

  2. 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.

    select modules

  3. This opens a terminal on your desktop and displays the installation stages.

    select modules

  4. After a few minutes, the install completes and you can press Return to close the installation dialog.

    select modules

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:

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.