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:
- Disable Secure Boot in firmware settings
- Verify GPT partition table with correct types
- Confirm ESP is FAT32 with proper mount options
- Ensure grub-efi is installed (not grub-pc)
- Regenerate grub config with serial console
- Install cloud-init for OCI integration
- Remove hardware-specific configurations
- 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.