如何在VirtualBox嵌套虚拟机中启用VT-x功能
Hey there! Let's work through your nested virtualization issue step by step. I’ve helped plenty of users solve this exact problem, so here’s a clear breakdown of how to get VT-x working inside your Ubuntu 16.04 guest, plus the full PCI Passthrough setup you asked about.
First: Enable VirtualBox's Nested Virtualization (Fix VT-x & 32-bit VM Creation)
This is the simplest and most reliable solution for your use case—VirtualBox has built-in support for nested VT-x, you just need to flip a few switches on your Windows host:
- Shut down your Ubuntu guest completely (make sure it’s not paused or hibernated—full shutdown only!)
- Tweak your VirtualBox VM settings:
- Open VirtualBox Manager, select your Ubuntu 16.04 VM, and click Settings
- Go to the System > Processor tab
- Check the box for Enable Nested VT-x/AMD-V
- Set the processor count to 2 or more (too few cores will cause 32-bit VM creation failures)
- Jump to the System > Motherboard tab and make sure Enable I/O APIC is checked
- Click OK to save changes
- Verify virtualization support in the Ubuntu guest:
- Boot up your Ubuntu guest, open a terminal, and run:
egrep -c '(vmx|svm)' /proc/cpuinfo - If the output is greater than 0, VT-x is now enabled!
- Boot up your Ubuntu guest, open a terminal, and run:
- Fix the 32-bit VM creation issue:
- Install KVM and essential virtualization tools in your Ubuntu guest—these are required to run nested VMs:
sudo apt update && sudo apt install -y qemu-kvm libvirt-bin virt-manager bridge-utils sudo usermod -aG libvirt $USER sudo usermod -aG kvm $USER - Reboot the guest, then open
virt-manageror your preferred VM tool—you should now be able to create 32-bit Ubuntu VMs without issues.
- Install KVM and essential virtualization tools in your Ubuntu guest—these are required to run nested VMs:
Second: PCI Passthrough Setup (For Direct Hardware Access)
Note: PCI Passthrough is primarily for passing physical PCI devices (like GPUs, network cards) directly to your guest VM. For nested virtualization, the above nested VT-x method is usually sufficient, but if you specifically need this approach, here’s how to configure it:
1. Prep Your Windows Host
- Enable IOMMU in BIOS: Reboot your Windows host and enter BIOS. Look for Intel VT-d (for Intel CPUs) or AMD-Vi (for AMD CPUs) and enable it. Save changes and boot back to Windows.
- Update VirtualBox Settings: With your Ubuntu guest shut down, go to Settings > System > Motherboard and ensure Enable I/O APIC is checked. For some devices, you may also need to check Enable EFI (special OSes only).
2. Identify the PCI Device to Pass Through
- On your Windows host, open Device Manager. Find the PCI device you want to pass through (e.g., a dedicated GPU, or if targeting virtualization capabilities, look for Intel Virtualization Technology-related devices).
- Right-click the device > Properties > Details > Hardware Ids and note the vendor ID and device ID (they’ll look like
VEN_XXXX&DEV_XXXX).
3. Configure VirtualBox PCI Passthrough
- With your Ubuntu guest shut down, go to Settings > PCI in VirtualBox Manager.
- Click the Add button, select the PCI device you want to pass through from the list.
- Check the Enable box (leave other settings at default unless you have specific needs) and click OK.
4. Set Up the Ubuntu Guest
- Boot your Ubuntu guest and install the appropriate drivers for the passed-through device (e.g., NVIDIA/AMD GPU drivers if you passed through a graphics card).
- Verify the device is working by running
lspciin the terminal—you should see the device listed, and it should function as if it’s physically installed in the guest.
Troubleshooting Tips
- If nested VT-x still doesn’t work: Double-check that VT-x is enabled in your Windows host’s BIOS (you can confirm in Task Manager > Performance > CPU—look for "Virtualization: Enabled").
- If PCI Passthrough fails: Not all consumer-grade hardware supports Passthrough. Ensure your device and motherboard explicitly support IOMMU/VT-d/AMD-Vi.
内容的提问来源于stack exchange,提问作者Sam

