Oracle Cloud Infrastructure Documentation

Preparing a Custom Linux Image for Import

Oracle Cloud Infrastructure enables you to import a custom Linux image and then use the custom image to launch virtual machine (VM) instances in emulation or paravirtualized mode. Before you can import the custom image, you need to prepare the custom image to ensure that instances launched from the custom image can boot correctly and that network connections will work. This topic describes the steps to prepare custom Linux images for import.

Enabling Serial Console Access

The most important step to prepare your custom image for import is to configure it to support connections using the serial console feature in the Compute service. For more information about this feature, see Instance Console Connections for troubleshooting steps if your image has network connectivity issues once launched.

The serial console connection in Oracle Cloud Infrastructure uses the first serial port, ttyS0, on the VM. The boot loader and the operating system should be configured to use ttyS0 as a console terminal for both input and output.

Configuring the Boot Loader

The steps to configure the boot loader to use ttyS0 as a console terminal for both input and output depend on the GRUB version. Run the following command on the operating system to determine the GRUB version:

grub install --version

If the version number returned is 2.* use the steps for GRUB 2. For earlier versions, use the steps for GRUB.

To configure GRUB
To configure GRUB2

Configuring the Operating System

The operating system may already be configured to use ttyS0 as a console terminal for both input and output. To verify, run the following command:

sudo vi /etc/securetty

Check the file for ttyS0. If you don't see it, append ttyS0 to the end of the file.

Validating Serial Console Access

After completing the steps to enable serial console access to the image, you should validate that serial console access is working by testing the image with serial console in your virtualization environment. Consult the documentation for your virtualization environment on how to do this. Verify that the boot output is showing up in the serial console output and that there is interactive input available once the image has booted.

Troubleshooting the Serial Console

If no output is displayed on the serial console, verify in the configuration for your virtualization environment that the serial console device is attached to the first serial port.

If the serial console is displaying output, but there is no interactive input available, check that there is a terminal process listening on the ttyS0 port. To do this, run the following command:

ps aux | grep ttyS0

This command should output a terminal process that is listening on the ttyS0 port. For example, if your system is using getty, you will see the following output:

/sbin/getty ttyS0

If you don't see this output, it is likely that a login process is not configured for the serial console connection. To resolve this, enable the init settings, so that a terminal process is listening on the ttyS0 at startup.

For example, if your system is using getty, add the following command to the the init settings to run on system startup:

getty -L 9600 ttyS0 vt102

The steps to do this will vary depending on the operating system, so consult the documentation for the image's operating system.

Network Configuration

Once a custom image is imported into Oracle Cloud Infrastructure, all existing NICs are replaced with a single NIC. You will need to configure the NIC to access to the internet. You need to ensure that DHCP is enabled on the NIC and that the MAC and IP addresses are not hardcoded. You can configure the NIC during the image preparation process or after the image has been imported to Oracle Cloud Infrastructure using serial console access to the instance. Consult your system documentation on how to perform network configuration for your system, and see Instance Console Connections.

Once the instance has been launched, you can attach and configure additional VNICs. See Virtual Network Interface Cards (VNICs) for more information.