This section describes how to use the features of Oracle VM VirtualBox to integrate with Oracle Cloud Infrastructure.
Integrating with Oracle Cloud Infrastructure involves the following steps:
-
Prepare for Oracle Cloud Infrastructure Integration. Before using Oracle VM VirtualBox with Oracle Cloud Infrastructure there are some initial configuration steps you may need to do. See Section 1.15.1, "Preparing for Oracle Cloud Infrastructure Integration".
-
Use Oracle VM VirtualBox with Oracle Cloud Infrastructure. Section 1.15.6, "Using Oracle VM VirtualBox With Oracle Cloud Infrastructure" describes how you can use Oracle VM VirtualBox with Oracle Cloud Infrastructure.
Perform the following configuration steps before using Oracle VM VirtualBox to integrate with your Oracle Cloud Infrastructure account.
-
Install the Extension Pack. Cloud integration features are only available when you install the Oracle VM VirtualBox Extension Pack. See Section 1.5, "Installing Oracle VM VirtualBox and Extension Packs".
-
Create a key pair. Generate an API signing key pair that is used for API requests to Oracle Cloud Infrastructure. See Section 1.15.2, "Creating an API Signing Key Pair".
Upload the public key of the key pair from your client device to the cloud service. See Section 1.15.3, "Uploading the Public Key to Oracle Cloud Infrastructure".
-
Create a cloud profile. The cloud profile contains resource identifiers for your cloud account, such as your user OCID, and details of your key pair. See Section 1.15.4, "Creating a Cloud Profile".
To use the cloud integration features of Oracle VM VirtualBox, you must generate an API signing key pair that is used for API requests to Oracle Cloud Infrastructure.
Your API requests are signed with your private key, and Oracle Cloud Infrastructure uses the public key to verify the authenticity of the request. You must upload the public key to the Oracle Cloud Infrastructure Console.
Note
This key pair is not the same SSH key that you use to access compute instances on Oracle Cloud Infrastructure.
-
(Optional) Create a
.oci
directory to store the key pair.$ mkdir ~/.oci
The key pair is usually installed in the
.oci
folder in your home directory. For example,~/.oci
on a Linux system. -
Generate the private key.
Use the openssl command.
-
To generate a private key with a passphrase:
$ openssl genrsa -out ~/.oci/oci_api_key.pem -aes128 2048
-
To generate a private key without a passphrase:
$ openssl genrsa -out ~/.oci/oci_api_key.pem 2048
-
-
Change permissions for the private key.
$ chmod 600 ~/.oci/oci_api_key.pem
Generate the public key.
$ openssl rsa -pubout -in ~/.oci/oci_api_key.pem -out ~/.oci/oci_api_key_public.pem
Use the following steps to upload your public key to Oracle Cloud Infrastructure.
-
Log in to the Oracle Cloud Infrastructure Console.
-
Display the User Settings page.
Click Profile, User Settings.
-
Display your current API signing keys.
Click Resources, API Keys.
-
Upload the public key.
Click Add Public Key.
The Add Public Key dialog is displayed.
Select one of the following options:
-
Choose Public Key File. This option enables you to browse to the public key file on your local hard disk.
-
Paste Public Keys. This option enables you to paste the contents of the public key file into the window in the dialog box.
Click Add to upload the public key.
-
Oracle VM VirtualBox uses a cloud profile to connect to Oracle Cloud Infrastructure. A cloud profile is a text file that contains details of your key files and Oracle Cloud Identifier (OCID) resource identifiers for your cloud account, such as the following:
-
Fingerprint of the public key. To obtain the fingerprint, you can use the openssl command:
$ openssl rsa -pubout -outform DER -in ~/.oci/oci_api_key.pem | openssl md5 -c
-
Location of the private key on the client device. Specify the full path to the private key.
-
(Optional) Passphrase for the private key.. This is only required if the key is encrypted.
-
Region. Shown on the Oracle Cloud Infrastructure Console. Click Administration, Tenancy Details.
-
Tenancy OCID. Shown on the Oracle Cloud Infrastructure Console. Click Administration, Tenancy Details.
A link enables you to copy the Tenancy OCID.
-
Compartment OCID. Shown on the Oracle Cloud Infrastructure Console. Click Identity, Compartments.
A link enables you to copy the Compartment OCID.
-
User OCID. Shown on the Oracle Cloud Infrastructure Console. Click Profile, User Settings.
A link enables you to copy the User OCID.
You can create a cloud profile in the following ways:
-
Automatically, by using the Cloud Profile Manager. See Section 1.15.5, "Using the Cloud Profile Manager".
The Cloud Profile Manager is a component of Oracle VM VirtualBox that enables you to create, edit, and manage cloud profiles for your cloud service accounts.
-
Automatically, by using the VBoxManage cloudprofile command. See Section 8.44, "VBoxManage cloudprofile".
-
Manually, by creating an
oci_config
file in your Oracle VM VirtualBox global configuration directory. For example, this is$HOME/.config/VirtualBox/oci_config
on a Linux host. -
Manually, by creating a
config
file in your Oracle Cloud Infrastructure configuration directory. For example, this is$HOME/.oci/config
on a Linux host.This is the same file that is used by the Oracle Cloud Infrastructure command line interface.
Oracle VM VirtualBox automatically uses the
config
file if no cloud profile file is present in your global configuration directory. Alternatively, you can import this file manually into the Cloud Profile Manager.
This section describes how to use the Cloud Profile Manager to create a cloud profile.
To open the Cloud Profile Manager click File, Cloud Profile Manager in the VirtualBox Manager window.
You can use the Cloud Profile Manager in the following ways:
-
To create a new cloud profile automatically
-
To create a cloud profile by importing settings from your Oracle Cloud Infrastructure configuration file.
Perform the following steps to create a new cloud profile automatically, using the Cloud Profile Manager:
-
Click the Add icon and specify a Name for the profile.
-
Click Properties and specify the following property values for the profile:
-
Compartment OCID
-
Fingerprint of the public key
-
Location of the private key on the client device
-
Region OCID
-
Tenancy OCID
-
User OCID
Some of these are settings for your Oracle Cloud Infrastructure account, which you can view from the Oracle Cloud Infrastructure Console.
-
-
Click Apply to save your changes.
The cloud profile settings are saved in the
oci_config
file in your Oracle VM VirtualBox global settings directory.
Perform the following steps to import an existing Oracle Cloud Infrastructure configuration file into the Cloud Profile Manager:
-
Ensure that a
config
file is present in your Oracle Cloud Infrastructure configuration directory. For example, this is$HOME/.oci/config
on a Linux host. -
Click the Import icon to open a dialog that prompts you to import cloud profiles from external files.
Warning
This action overwrites any cloud profiles that are in your Oracle VM VirtualBox global settings directory.
-
Click Import.
Your cloud profile settings are saved to the
oci_config
file in your Oracle VM VirtualBox global settings directory. -
Click Properties to show the cloud profile settings.
Double-click on the appropriate field to change the value.
-
Click Apply to save your changes.
This section describes how you can use Oracle VM VirtualBox with Oracle Cloud Infrastructure to do the following tasks:
-
Export an Oracle VM VirtualBox VM to Oracle Cloud Infrastructure. See Section 1.15.7, "Exporting an Appliance to Oracle Cloud Infrastructure".
-
Import a cloud instance into Oracle VM VirtualBox. See Section 1.15.8, "Importing an Instance from Oracle Cloud Infrastructure".
-
Create a new cloud instance from a custom image stored on Oracle Cloud Infrastructure. See Section 1.15.9, "Creating New Cloud Instances from a Custom Image".
-
Use the VBoxManage commands to integrate with Oracle Cloud Infrastructure and perform cloud operations. See Section 1.15.10, "Using VBoxManage Commands With Oracle Cloud Infrastructure".
Oracle VM VirtualBox supports the export of VMs to an Oracle Cloud Infrastructure service. The exported VM is stored on Oracle Cloud Infrastructure as a custom Linux image. You can configure whether a cloud instance is created and started after the export process has completed.
Note
Before you export a VM to Oracle Cloud Infrastructure, you must prepare the VM as described in Section 1.15.7.1, "Preparing a VM for Export to Oracle Cloud Infrastructure".
Use the following steps to export a VM to Oracle Cloud Infrastructure:
-
Select File, Export Appliance to open the Export Virtual Appliance wizard.
Select a VM to export and click Next to open the Appliance Settings screen.
-
From the Format drop-down list, select Oracle Cloud Infrastructure.
In the Account drop-down list, select the cloud profile for your Oracle Cloud Infrastructure account.
The list after the Account field shows the profile settings for your cloud account.
In the Machine Creation field, select an option to configure settings for a cloud instance created when you export to Oracle Cloud Infrastructure. The options enable you to do one of the following:
-
Configure settings for the cloud instance after you have finished exporting the VM.
-
Configure settings for the cloud instance before you start to export the VM.
-
Do not create a cloud instance when you export the VM.
Click Next to make an API request to the Oracle Cloud Infrastructure service and open the Virtual System Settings screen.
-
-
(Optional) Edit storage settings used for the exported virtual machine in Oracle Cloud Infrastructure. You can change the following settings:
-
The name of the bucket used to store the exported files.
-
Whether to store the custom image in Oracle Cloud Infrastructure.
-
The name for the custom image in Oracle Cloud Infrastructure.
-
The launch mode for the custom image.
Paravirtualized mode gives improved performance and should be suitable for most Oracle VM VirtualBox VMs.
Emulated mode is suitable for legacy OS images.
Click Export to continue.
-
-
Depending on the selection in the Machine Creation field, the Cloud Virtual Machine Settings screen may be displayed before or after export. This screen enables you to configure settings for the cloud instance, such as Shape and Disk Size.
Click Create. The VM is exported to Oracle Cloud Infrastructure.
Depending on the Machine Creation setting, a cloud instance may be started after upload to Oracle Cloud Infrastructure is completed.
-
Monitor the export process by using the Oracle Cloud Infrastructure Console.
You can also use the VBoxManage export command to export a VM to Oracle Cloud Infrastructure. See Section 8.11.2, "Export to Oracle Cloud Infrastructure".
Oracle Cloud Infrastructure provides the option to import a custom Linux image. Before an Oracle VM VirtualBox image can be exported to Oracle Cloud Infrastructure, the custom image needs to be prepared to ensure that instances launched from the custom image can boot correctly and that network connections will work. This section provides advice on how to prepare a Linux image for export from Oracle VM VirtualBox.
The following list shows some tasks to consider when preparing an Oracle Linux VM for export:
-
Use DHCP for network addresses. Configure the VM to use a DHCP server to allocate network addresses, rather than using a static IP address. The Oracle Cloud Infrastructure instance will then be allocated an IP address automatically.
-
Do not specify a MAC address. The network interface configuration for the VM must not specify the MAC address.
Remove the HWADDR setting from the
/etc/sysconfig/ifcfg-
network script.devicename
-
Disable persistent network device naming rules. This means that the Oracle Cloud Infrastructure instance will use the same network device names as the VM.
-
Change the GRUB kernel parameters.
Add
net.ifnames=0
andbiosdevname=0
as kernel parameter values to theGRUB_CMDLINE_LINUX
variable. -
Update the GRUB configuration.
# grub2-mkconfig -o /boot/grub2/grub.cfg
-
Disable any
udev
rules for network device naming.For example, if an automated
udev
rule exists fornet-persistence
:# cd /etc/udev/rules.d # rm -f 70-persistent-net.rules # ln -s /dev/null /etc/udev/rules.d/70-persistent-net.rules
-
-
Enable the serial console. This enables you to troubleshoot the instance when it is running on Oracle Cloud Infrastructure.
-
Edit the
/etc/default/grub
file, as follows:-
Remove the
resume
setting from the kernel parameters. This setting slows down boot time significantly. -
Replace
GRUB_TERMINAL="gfxterm"
withGRUB_TERMINAL="console serial"
. This configures use of the serial console instead of a graphical terminal. -
Add
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"
. This configures the serial connection. -
Add
console=tty0 console=ttyS0,115200
to theGRUB_CMDLINE_LINUX
variable. This adds the serial console to the Linux kernel boot parameters.
-
-
Regenerate the GRUB configuration.
# grub2-mkconfig -o /boot/grub2/grub.cfg
-
To verify the changes, reboot the machine and run the dmesg command to look for the updated kernel parameters.
# dmesg |grep console=ttyS0
-
-
Enable paravirtualized device support. You do this by adding the
virtio
drivers to theinitrd
for the VM.-
This procedure works only on machines with a Linux kernel of version 3.4 or later. Check that the VM is running a supported kernel:
# uname -a
-
Use the
dracut
tool to rebuildinitrd
. Add theqemu
module, as follows:# dracut --logfile /var/log/Dracut.log --force --add qemu
-
Verify that the
virtio
drivers are now present ininitrd
.# lsinitrd |grep virtio
-
For more information about importing a custom Linux image into Oracle Cloud Infrastructure, see also:
https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/importingcustomimagelinux.htm
Perform the following steps to import a cloud instance from Oracle Cloud Infrastructure into Oracle VM VirtualBox:
-
Select File, Import Appliance to open the Import Virtual Appliance wizard.
In the Source drop-down list, select Oracle Cloud Infrastructure.
In the Account drop-down list, select the cloud profile for your Oracle Cloud Infrastructure account.
The list after the Account field shows the profile settings for your cloud account.
Choose the required cloud instance from the list in the Machines field.
Click Next to make an API request to the Oracle Cloud Infrastructure service and display the Appliance Settings screen.
-
(Optional) Edit settings for the new local virtual machine.
For example, you can edit the VM name and description.
Click Import to import the instance from Oracle Cloud Infrastructure.
-
Monitor the import process by using the Oracle Cloud Infrastructure Console.
You can also use the VBoxManage import command to import an instance from Oracle Cloud Infrastructure. See Section 8.10.2, "Import from Oracle Cloud Infrastructure".
The following describes the sequence of events when you import an instance from Oracle Cloud Infrastructure.
-
A custom image is created from the boot volume of the instance.
-
The custom image is exported to an Oracle Cloud Infrastructure object and is stored using Object Storage in the bucket specified by the user.
-
The Oracle Cloud Infrastructure object is downloaded to the local host. The object is a TAR archive which contains a boot volume of the instance in QCOW2 format and a JSON file containing metadata related to the instance.
-
The boot volume of the instance is extracted from the archive and a new VMDK image is created by converting the boot volume into the VMDK format. The VMDK image is registered with Oracle VM VirtualBox.
-
A new VM is created using the VMDK image for the cloud instance.
By default, the new VM is not started after import from Oracle Cloud Infrastructure.
-
The downloaded TAR archive is deleted after a successful import.
You can use Oracle VM VirtualBox to create new instances from a custom image on your cloud service.
Section 1.15.7, "Exporting an Appliance to Oracle Cloud Infrastructure" describes how to create a custom image when you are exporting a VM to Oracle Cloud Infrastructure. Using a custom image means that you can quickly create cloud instances without having to upload your image to the cloud service every time.
Perform the following steps to create a new cloud instance on Oracle Cloud Infrastructure:
-
Select File, New Cloud VM to open the Create Cloud Virtual Machine wizard.
-
From the Destination drop-down list, select Oracle Cloud Infrastructure.
In the Account drop-down list, select the cloud profile for your Oracle Cloud Infrastructure account.
The list after the Account field shows the profile settings for your cloud account.
In the Images list, select from the custom images available on Oracle Cloud Infrastructure.
Click Next to make an API request to the Oracle Cloud Infrastructure service and open the Cloud Virtual Machine Settings screen.
-
(Optional) Edit settings used for the new instance on Oracle Cloud Infrastructure.
For example, you can edit the Disk Size and Shape used for the VM instance and the networking configuration.
Click Create to create the new cloud instance.
-
Monitor the instance creation process by using the Oracle Cloud Infrastructure Console.
You can also use the VBoxManage cloud instance command to create and manage instances on a cloud service. See Section 8.45, "VBoxManage cloud".
This section includes some examples of how VBoxManage commands can be used to integrate with Oracle Cloud Infrastructure and perform common cloud operations.
Creating a Cloud Profile
To create a cloud profile called vbox-oci
:
VBoxManage cloudprofile --provider "OCI" --profile="vbox-oci" add \ --clouduser="ocid1.user.oc1..." --keyfile="/home/username/.oci/oci_api_key.pem" \ --tenancy="ocid1.tenancy.oc1..." --compartment="ocid1.compartment.oc1..." --region="us-ashburn-1"
The new cloud profile is added to the oci_config
file in your Oracle VM VirtualBox global configuration directory. For example, this is $HOME/.VirtualBox/oci_config
on a Windows host.
Listing Cloud Instances
To list the instances in your Oracle Cloud Infrastructure compartment:
VBoxManage cloud --provider="OCI" --profile="vbox-oci" list instances
Exporting an Oracle VM VirtualBox VM to the Cloud
To export a VM called myVM
and create a cloud instance called myVM_Cloud
:
VBoxManage export myVM --output OCI:// --cloud 0 --vmname myVM_Cloud \ --cloudprofile "vbox-oci" --cloudbucket myBucket \ --cloudshape VM.Standard2.1 --clouddomain US-ASHBURN-AD-1 --clouddisksize 50 \ --cloudocivcn ocid1.vcn.oc1... --cloudocisubnet ocid1.subnet.oc1... \ --cloudkeepobject true --cloudlaunchinstance true --cloudpublicip true
Importing a Cloud Instance Into Oracle VM VirtualBox
To import a cloud instance and create an Oracle VM VirtualBox VM called oci_Import
:
VBoxManage import OCI:// --cloud --vmname oci_Import --memory 4000 --cpus 3 --ostype FreeBSD_64 --cloudprofile "vbox-oci" --cloudinstanceid ocid1.instance.oc1... --cloudbucket myBucket
Creating a New Cloud Instance From a Custom Image
To create a new cloud instance from a custom image on Oracle Cloud Infrastructure:
VBoxManage cloud --provider="OCI" --profile="vbox-oci" instance create \ --domain-name="oraclecloud.com" --image-id="ocid1.image.oc1..." --display-name="myInstance" \ --shape="VM.Standard2.1" --subnet="ocid1.subnet.oc1..."
Terminating a Cloud Instance
To terminate an instance in your compartment on Oracle Cloud Infrastructure:
VBoxManage cloud --provider="OCI" --profile="vbox-oci" instance terminate \ --id="ocid1.instance.oc1..."
For more details about the available commands for cloud operations, see Section 8.45, "VBoxManage cloud".