On Oracle Ubuntu 22 ARM instance I get:

> Warning: KVM is not available. This may mean the KVM package is not installed, or the KVM kernel modules are not loaded. Your virtual machines may perform poorly.

How to solve this issue?
Aug 12, 12:57am

The warning you're encountering on your Oracle Ubuntu 22.04 ARM instance indicates that KVM (Kernel-based Virtual Machine) is not available. This can happen for several reasons, such as:

  1. KVM is not installed on the system.
  2. KVM kernel modules are not loaded.
  3. Virtualization extensions are not enabled in the BIOS/UEFI (though this is less likely on cloud instances).
  4. The system does not support nested virtualization (common in cloud environments).

Since you're using an Oracle Cloud ARM instance, nested virtualization is often disabled by default for security and performance reasons. However, you can still check and attempt to enable KVM if your instance supports it.


Steps to Diagnose and Fix the Issue

1. Check if KVM is Supported on Your Instance

Run the following command to check if your CPU supports virtualization:

bash
egrep -c '(vmx|svm)' /proc/cpuinfo
  • If the output is 0, your CPU does not support hardware virtualization (common on ARM instances unless explicitly enabled).
  • If the output is 1 or higher, your CPU supports virtualization, but KVM may still be disabled.

For ARM-based systems, check for KVM support with:

bash
ls /dev/kvm
  • If /dev/kvm exists, KVM is available.
  • If it does not exist, KVM is not available.

2. Install KVM (if not installed)

If KVM is supported but not installed, run:

bash
sudo apt update
sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils

3. Load KVM Kernel Modules

If KVM is installed but the modules are not loaded, run:

bash
sudo modprobe kvm
sudo modprobe kvm_arm  # For ARM-based systems

Check if the modules are loaded:

bash
lsmod | grep kvm

If you see kvm and kvm_arm in the output, the modules are loaded.


4. Check if Nested Virtualization is Enabled

On Oracle Cloud ARM instances, nested virtualization is often disabled by default. You can check if it's enabled with:

bash
cat /sys/module/kvm_arm/parameters/nested
  • If the output is Y or 1, nested virtualization is enabled.
  • If the output is N or 0, it is disabled.

Enabling Nested Virtualization (if supported)

Nested virtualization is not always supported on ARM instances in the cloud. If your instance supports it, you can try enabling it with:

bash
echo "options kvm_arm nested=1" | sudo tee /etc/modprobe.d/kvm_arm.conf
sudo modprobe -r kvm_arm
sudo modprobe kvm_arm

Then verify:

bash
cat /sys/module/kvm_arm/parameters/nested

5. Restart Required Services

After making changes, restart the libvirtd service:

bash
sudo systemctl restart libvirtd

6. Verify KVM Availability

Run:

bash
kvm-ok
  • If the output says KVM acceleration can be used, KVM is working.
  • If not, KVM is still not available.

7. Fallback: Use QEMU with TCG (if KVM is unavailable)

If KVM is not available (e.g., nested virtualization is disabled on your cloud instance), you can still run VMs using QEMU with TCG (Tiny Code Generator), but performance will be significantly slower.

To use QEMU without KVM:

bash
qemu-system-aarch64 -enable-kvm  # This will fail if KVM is unavailable
qemu-system-aarch64              # Falls back to TCG (slow)

Oracle Cloud-Specific Notes

  • Oracle Cloud ARM instances (e.g., Ampere A1) do not support nested virtualization by default. You cannot enable KVM inside an Oracle Cloud ARM instance for running nested VMs. If you need KVM, consider using an x86_64 instance (e.g., Intel or AMD) where nested virtualization is often supported.

  • If you must use ARM, you can only run VMs in emulation mode (TCG), which is very slow and not recommended for production.


Summary of Solutions

KVM not installed
Install KVM (sudo apt install qemu-kvm libvirt-daemon-system)
KVM modules not loaded
Load modules (sudo modprobe kvm kvm_arm)
Nested virtualization disabled
Enable nested virtualization (if supported)
Oracle Cloud ARM instance
KVM is not available; use QEMU TCG (slow) or switch to x86_64

Recommendation

If you're using Oracle Cloud ARM instances, KVM is not available for nested virtualization. You have two options:

  1. Use an x86_64 instance (e.g., Intel/AMD) where KVM is supported.
  2. Run VMs in emulation mode (TCG) with qemu-system-aarch64 (not recommended for performance-critical workloads).
Aug 12, 12:57am

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more