82

Is it possible to, say, run VirtualBox on Windows 7 with a Linux guest, and inside that Linux machine run Bochs?

The reason is that I'm interested in starting OS development, and I've found that all the tutorials and stuff are much easier to follow on *nix machines. I tried using Cygwin, but I think it's adding another layer of complexity and not necessarily making things easier.

jpaugh
  • 1,390
Javier
  • 3,935

8 Answers8

63

Long story short: yes.

Each virtual machine is technically "independent" of one another, and with VirtualBox, you could easily do this, since it is supported on both Windows and Linux host operating systems (emulated or not). You could simply use Windows as your "base-host" OS, run Linux in a VM, and then use that operating system as the new base-host for Bochs.

Do note that your only limitation here is your hardware. Depending on the requirements of your development, you may require more memory, or an upgrade to a 64-bit "base-host" operating system. That being said, if you choose your Linux distros wisely, any modern system should be capable of arbitrary nesting like this.

You will see improved performance if you enable x86 virtualization support on your computer (if your motherboard and CPU support it), and AFAIK, you can "pass through" this feature to multiple nested virtual machines. If we have n virtual machines nested in eachother, this is supported so long as the 1st to the n-1th nested guest OS has support for x86 virtualization (the base host must also support it). Do note that there are still some security issues to be aware of if you do this, so take the appropriate precautions.

Breakthrough
  • 34,847
40

I sometimes run a whole VMware vSphere virtual infrastructure within VMware Workstation, along with virtual Cisco routers and switches and EMC Celerra Virtualized Storage Appliance, for self-learning and testing purposes.

I call it 'Inception Computing', and it can get pretty confusing. It is however somewhat cheaper than using the real gear.

paradroid
  • 23,297
31

To anyone who reads this question, sees the accepted answer, and thinks this will apply to VirtualBox as well, please see comment from @superbatfish on the original question. He makes a good point about the difference between virtualization and emulation.

Specifically, "hardware assisted VM" will not be available in the "top-level" guest OS (that is, at the time of this writing, VirtualBox doesn't provide hardware VM in guest OSes). With VirtualBox, this means you can only create 32-bit "nested guest" OSes, even if the top-level guest is 64 bit and your "real" host has hardware VM.

May not be a showstopper for you, but it's worth noting. I needed this in order to run Vagrant on an Ubuntu guest inside Windows, for Chef cookbook testing.

Tobias J
  • 1,352
10

Linux-KVM has some support for nested virtual machines. I've asked on the KVM IRC channel and have gotten the following information (but don't take my word, try it yourself):

  • AMD CPUs should work well, guests with Xen and Hyper-V are known to work,
  • Intel CPUs need the latest KVM Git source code, and only guests with KVM work

I haven't tried this myself yet. A search for "KVM nested" should give you enough info to try it yourself.

EDIT: KVM will run on a Linux host only. I haven't gotten any reliable info on Windows virtualization software concerning proper nested VM support. By 'proper' I mean that the hypervisor exposes virtualization extensions to the guest. You can always run a nested VM using a pure software hypervisor (e.g. dynamic translation), but that will be noticably slower.

EDIT: Bochs, which you mentioned, is a software-only hypervisor. This means that it will always be slow, and it's irrelevent if the hypervisor on the host exposes virtualization extensions to the guest (like KVM does). Most other virtualization softare (KVM, VirtualBox, VMWare) however can make use of those extensions and will perform much better if they are available.

2

Its possible, but not very feasible, especially for development. You should probably look at running Linux as your native OS, or getting a second box to host the VMs on.

peelman
  • 4,891
1

Detailed description of this process is on this page: https://wiki.openstack.org/wiki/XenServer/VirtualBox

In VirtualBox machine network cards you have to set allow all in Promiscuous Mode and several other options and you can have os inside vm e.g. Xenserver inside vm e.g. VirtualBox.

42n4
  • 111
0

Yes, it is possible, given that your computer is powerful enough to handle it.

On my machine (i7 4770S, 16GB RAM) I managed to get a VM-ception-ness level of 4.5 (the last one crashes half of the time).

I used VMware Player 12, because VirtualBox didn't like emulating VM-x, and it was reaaaally slower. Right now, I'm trying to make W2K work on XP, but VMware can't install, VirtualBox produces BSODs so I'm trying using QEMU.

See this screenshot (one of the most beautiful screenshots I've ever seen):

enter image description here

Gareth
  • 19,080
zdimension
  • 14,283
0

Yes, you can run a virtual machine in a virtual machine. What I did was get a Windows 7 Ultimate x64 computer, run the same OS on the virtual machine, then run a 32 bit version (it couldn't handle 64 bit on the 3rd layer) on the 3rd layer. It was pretty laggy but i managed to get to the new york times on internet explorer with it. This may be difficult if you don't have a powerful computer, but you're running Linux and Bochs, which are lightweight Operating Systems, so it should be possible.