Compute instance boot failure after importing custom image with UEFI firmware

I’ve imported a custom Linux image (Ubuntu 22.04) from our on-premises environment to OCI, but compute instances fail to boot from it. The import completes successfully, but launching an instance results in boot errors.

The source VM uses UEFI firmware with Secure Boot enabled and GPT partitioning. During import, I specified --launch-mode PARAVIRTUALIZED but instances hang at boot with no console output.


oci compute image import from-object \
  --display-name ubuntu-custom-uefi \
  --launch-mode PARAVIRTUALIZED \
  --operating-system Linux

Image shows as ‘Available’ in console, but instance provisioning gets stuck at ‘Provisioning’ state for 10+ minutes before failing. Is there a specific UEFI configuration or bootloader requirement for custom images in OCI? Our on-prem VM boots fine with the same disk image.

UEFI boot in OCI requires specific configuration. When you import a UEFI-based image, you must use --launch-mode NATIVE instead of PARAVIRTUALIZED. Native mode supports UEFI firmware, while paravirtualized mode only supports legacy BIOS boot.

Also verify your image has the EFI System Partition (ESP) properly configured with bootloader files in /boot/efi. The ESP must be FAT32 formatted and contain the UEFI bootloader (typically /boot/efi/EFI/ubuntu/grubx64.efi for Ubuntu).

Excellent troubleshooting! Let me provide a comprehensive solution covering all three critical areas for UEFI custom image imports.

1. UEFI Boot Support in OCI:

OCI requires Native launch mode for UEFI firmware. The correct import command:

oci compute image import from-object \
  --compartment-id ocid1.compartment.oc1..xxx \
  --bucket-name custom-images \
  --namespace your-namespace \
  --name ubuntu-uefi-image.qcow2 \
  --display-name "Ubuntu 22.04 UEFI Custom" \
  --launch-mode NATIVE \
  --operating-system Linux \
  --operating-system-version "22.04"

Key requirements:

  • --launch-mode NATIVE (mandatory for UEFI)
  • Disable Secure Boot on source VM before export
  • Remove any hardware-specific UEFI settings
  • Ensure image format is QCOW2 or VMDK (OCI converts automatically)

2. GPT Partition Table Configuration:

Your disk must have proper GPT layout with correct partition types:

# Verify GPT structure on source VM:
gdisk -l /dev/sda

# Expected output:
Number  Start   End      Size       Code  Name
1       2048    1050623  512.0 MiB  EF00  EFI System Partition
2       1050624 END      XXX.X GiB  8300  Linux filesystem

Critical partition requirements:

  • ESP (partition 1) must be type EF00 with GUID C12A7328-F81F-11D2-BA4B-00A0C93EC93B
  • ESP size: 512MB minimum (recommended)
  • ESP filesystem: FAT32 (vfat)
  • Root partition (partition 2): type 8300 for Linux

If partition types are incorrect:

# Fix partition type (don't format, just change type)
gdisk /dev/sda
# Press 't' for partition type
# Select partition 1
# Enter 'EF00' for EFI System Partition
# Press 'w' to write changes

3. EFI Bootloader Files and Configuration:

Proper UEFI bootloader setup is critical:

Install GRUB for UEFI:

# On Ubuntu/Debian source VM:
apt-get install grub-efi-amd64 grub-efi-amd64-bin

# Mount ESP if not mounted:
mount /dev/sda1 /boot/efi

# Install GRUB to EFI partition:
grub-install --target=x86_64-efi --efi-directory=/boot/efi \
  --bootloader-id=ubuntu --recheck --no-floppy

Verify bootloader files exist:

ls -la /boot/efi/EFI/ubuntu/
# Must contain: grubx64.efi, shimx64.efi (if using shim)

Configure /etc/fstab for ESP:

# Get ESP UUID:
blkid /dev/sda1

# Add to /etc/fstab:
UUID=XXXX-XXXX  /boot/efi  vfat  umask=0077,shortname=winnt  0  1

Update GRUB configuration:

# Edit /etc/default/grub - add console output:
GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"

# Regenerate grub.cfg:
grub-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg

Verify UEFI boot entries:

efibootmgr -v
# Should show Ubuntu entry pointing to grubx64.efi

Pre-Export Checklist:

  1. Disable Secure Boot in firmware settings
  2. Verify GPT partition table with correct types
  3. Confirm ESP is FAT32 with proper mount options
  4. Ensure grub-efi is installed (not grub-pc)
  5. Regenerate grub config with serial console
  6. Install cloud-init for OCI integration
  7. Remove hardware-specific configurations
  8. Clean up /etc/udev/rules.d/ (remove MAC-specific rules)

Boot Performance Optimization:

For faster boot times:

  • Use paravirtualized drivers (virtio) in kernel
  • Disable unnecessary systemd services
  • Remove grub boot delay: GRUB_TIMEOUT=0 in /etc/default/grub
  • Enable parallel service startup in systemd

Your boot time issue is likely due to grub timeout or missing virtio drivers. Add virtio_blk and virtio_net to initramfs, then regenerate with update-initramfs -u.

After making these changes, export the disk as QCOW2, upload to Object Storage, and import with Native launch mode. Your instances should boot cleanly in under 60 seconds.

Slow boot with UEFI images often indicates the bootloader is searching for devices or waiting on timeouts. Check your grub.cfg for unnecessary disk searches or network boot attempts. Also ensure you’re using paravirtualized drivers (virtio) for disk and network in your kernel - legacy drivers cause slower initialization.

Add console=ttyS0 to your kernel boot parameters in grub.cfg to see detailed boot messages in the instance console. This will help identify where the delay occurs.