Actions

Nested Virtualization

From Whonix


Mastomys-332686640.jpg

Introduction[edit]

It is possible to run virtual machines (VMs) inside other VMs. That is called nested virtualization: [1]

Nested virtualization refers to virtualization that runs inside an already virtualized environment. In other words, it's the ability to run a hypervisor inside of a virtual machine (VM), which itself runs on a hypervisor.

With nested virtualization, you're effectively nesting a hypervisor within a hypervisor. The hypervisor running the main virtual machine is considered a level 0, or LO hypervisor, and the initial hypervisor running inside the virtual machine is referred to as a level 1 or L1 hypervisor. Further nested virtualization would result in a level 2 (L2) hypervisor inside the nested VM, then a level 3 (L3) hypervisor within that nested VM, and so forth.

Not all hypervisors and operating systems support nested virtualization.

Free Support Principle applies.

Security Considerations[edit]

Nested virtualization isn't a by-product of developing a virtualizer. Just by developing a functional virtualizer there is not automatically offerthe possibility to run nested virtualization of its own or third party virtualizers. For example while the virtualizer VirtualBox existed for years, the ability to run VirtualBox inside VirtualBox using Intel CPUs was only released in VirtualBox 6.1 in 2020. [2] This demonstrates that extra code is required for this functionality and extra code means more attack surface.

By mixing virtualizers, for example by running the virtualizer VirtualBox inside another virtualizer VMware the attack surface increases as both virtualizer code gets involved.

Qubes[edit]

Running VirtualBox, KVM or Qubes inside Qubes is difficult and is not offically supported by the Qubes developers; this is unrelated to Whonix ™. To learn more about the current state of support, search the qubes-devel [archive] and qubes-users [archive] mailing lists for terms such as VirtualBox, KVM and/or nested virtualization.

KVM[edit]

See Nested KVM Virtualization.

VirtualBox inside VirtualBox[edit]

On the host. (L0)

  1. Power off the VM (L1) if running.
  2. Change your host key: VirtualBoxPreferencesInputHost Key. The "outside" (L0) and the "inside" (L1) Host Key must differ, otherwise you can not leave the "inside" (L1) VM anymore.
  3. Enable nested virtualization. VirtualBoxclick a VMSettingsSystemProcessorEnable 'Nested VT-x/AMD-VOK (If that does not work, see footnote.) [3]
  4. Assign less virtual CPUs. For example if your host has 4 physical CPU cores, reduce the VM to 3. [4] VirtualBoxclick a VMSettingsSystemProcessorReduce to 3OK
  5. Increase virtual RAM. Virtual machineMenuSettingsAdjust Memory sliderClick: OK
  6. Using I/O APIC can speed up the VM. VirtualBoxright-click on VMSettingsSystemcheck "Enable I/O APIC"Click: OK [5] [6] [7]
  7. Power on the VM (L1).

Inside the VM (L1).

  1. Install VirtualBox.

Install virtualbox.

1. Update the package lists.

sudo apt-get update

2. Upgrade the system.

sudo apt-get dist-upgrade

3. Install the virtualbox package.

sudo apt-get install virtualbox

The procedure of installing virtualbox is complete.

  1. Now you should be able to use VirtualBox inside the VM (L1).
  2. If your VM (L1) has 3 "physical" (actually virtual CPU cores) do not assign more than 2 virtual CPU cores to VM (L2). Start with 1 virtual CPU for the VM (L2). If that works well for you, feel free to experiment increasing. VirtualBoxclick a VMSettingsSystemProcessorIncrease to 2OK

Running Whonix ™ in a Nested Virtual Machine[edit]

Only Whonix ™ 64-bit builds are available for download. See Dev/64bit for why. Some virtualizers have no or limited support running nested VMs that require 64-bit. This might be an issue when trying to run Whonix ™ in a nested virtual machine.

See Also[edit]

Footnotes[edit]

  1. https://www.webopedia.com/TERM/N/nested-virtualization.html [archive]
  2. https://www.virtualbox.org/ticket/4032#comment:163 [archive]

    Hardware-assisted Nested virtualization on Intel CPUs has been available starting with VirtualBox 6.1.0

  3. Replace Whonix-Workstation-XFCE with the actual name of the VM in case you renamed the VM or are using multiple Whonix-Workstation ™. The following command works on Linux. Untested on Windows but should be possible to make this command work on Windows as well. It's only about adding VBoxManage to PATH (if that is not the default) or using the full path to VBoxManage.
    VBoxManage modifyvm Whonix-Workstation-XFCE --nested-hw-virt on

  4. https://www.virtualbox.org/ticket/19500 [archive]
  5. vboxmanage "Whonix-Workstation" modifyvm --ioapic on

  6. So does enabling ACPI. Enabling ACPI in all VMs significantly speeds up the "inside" VM (L1).
    vboxmanage "Whonix-Workstation" modifyvm --acpi on

    Quote https://www.virtualbox.org/manual/ch03.html#settings-motherboard [archive]

    ACPI is the current industry standard to allow OSes to recognize hardware, configure motherboards and other devices and manage power. As most computers contain this feature and Windows and Linux support ACPI, it is also enabled by default in Oracle VM VirtualBox.

  7. These settings are in use for Whonix ™ VMs by default.


text=Jobs in USA
Jobs in USA


Search engines: YaCy | Qwant | ecosia | MetaGer | peekier | Whonix ™ Wiki


Follow: Twitter.png Facebook.png 1280px-Gab text logo.svg.png Iconfinder news 18421.png Rss.png Matrix logo.svg.png 1024px-Telegram 2019 Logo.svg.png Discourse logo.svg Reddit.jpg Diaspora.png Gnusocial.png Mewe.png 500px-Tumblr Wordmark.svg.png Iconfinder youtube 317714.png 200px-Minds logo.svg.png 200px-Mastodon Logotype (Simple).svg.png 200px-LinkedIn Logo 2013.svg.png

Donate: Donate Bank Wire Paypal Bitcoin accepted here Monero accepted here Contriute

Whonix donate bitcoin.png Monero donate whonix.png United Federation of Planets 1000px.png

Share: Twitter | Facebook

We are looking for contributors and developers.

https link onion link

This is a wiki. Want to improve this page? Help is welcome and volunteer contributions are happily considered! Read, understand and agree to Conditions for Contributions to Whonix ™, then Edit! Edits are held for moderation. Policy of Whonix Website and Whonix Chat and Policy On Nonfreedom Software applies.

Copyright (C) 2012 - 2020 ENCRYPTED SUPPORT LP. Whonix ™ is a trademark. Whonix ™ is a licensee [archive] of the Open Invention Network [archive]. Unless otherwise noted, the content of this page is copyrighted and licensed under the same Freedom Software license as Whonix ™ itself. (Why?)

Whonix ™ is a derivative of and not affiliated with Debian [archive]. Debian is a registered trademark [archive] owned by Software in the Public Interest, Inc [archive].

Whonix ™ is produced independently from the Tor® [archive] anonymity software and carries no guarantee from The Tor Project [archive] about quality, suitability or anything else.

By using our website, you acknowledge that you have read, understood and agreed to our Privacy Policy, Cookie Policy, Terms of Service, and E-Sign Consent. Whonix ™ is provided by ENCRYPTED SUPPORT LP. See Imprint, Contact.