34

We have a test system where a VirtualBox VM snapshot is started before each major test. The snapshot contains a state of the tested system specific to the test.

This is a memory-intensive testing.

There is an idea to move the daily test run into Amazon EC2 Large instance (7.5G of RAM).

My understanding though is that EC2 is a supervisor itself. Will it allow another VM software (VirtualBox) to get started under it?

David Wolever
  • 130,273
  • 78
  • 311
  • 472
Vladimir Dyuzhev
  • 17,603
  • 9
  • 45
  • 61

8 Answers8

22

Well, Amazon now allows to import VirtualBox and VMWare VMs. Not all operation systems are supported yet, but they work on it:

http://aws.amazon.com/ec2/vmimport/

So there is no need to run VirtualBox under Amazon, one can just import and clone the VM as an instance.

Vladimir Dyuzhev
  • 17,603
  • 9
  • 45
  • 61
  • 5
    seem that it does not support Virtualbox vmdk file. None of the docs on AWS mentions Virtualbox: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/VMImportPrerequisites.html – Harry Jun 04 '14 at 11:38
  • 1
    There is a need: B/SaaS applications might want tons of ultra small machines - 1 per user. – mylord Jul 27 '15 at 13:30
  • EC2 does not support virtualbox importing at all, it's a shame because virtualbox can export as OVA, OVF 1.0, OVF 2.0 and can also export as VMDK and all the other hard drive images that are supported –  Jun 20 '16 at 15:29
  • 5
    The question title "Can VirtualBox be executed under Amazon EC2 instance?" is not answered here. There are many needs to run VirtualBox and VMWare, one example is build automation that creates images for those virtualization providers. – Steve Buzonas Sep 01 '16 at 17:19
10

No, I don't believe it will.

I'm not 100% clear on exactly why, but my understanding is that the VirtualBox host needs access to ring 0, but since your host will be running in a virtualized system it won't be able to get this access.

If you really want to run virtual machines inside other virtual machines, you can use QEMU. Because it is an a processor emulator it doesn't depend on any of the underlying hardware, so it will work “anywhere”. The downside, though, is that it's much slower.

David Wolever
  • 130,273
  • 78
  • 311
  • 472
  • David, do you have any more information on this? I'm trying to install QEMU on a 64-bit CentOS 6.4, although I'm having a little trouble finding resources – blong Apr 03 '14 at 17:05
9

I have run VirtualBox under a Windows AMI. I'm trying to run it under Linux but there are all sorts of dependencies and hassles. It is painfully slow. So the answer is "yes" but you probably don't want to do it unless you're really desperate.

Max Allan
  • 625
  • 7
  • 20
  • could you provide a guide on how to do that in amazon linux? – Misha Slyusarev Aug 18 '16 at 21:04
  • As I recall, you can get it to run 32bit OSes in an "emulated" mode (not quite "real" virtualisation). This mechanism avoids the need for "ring 0" access, but at a heavy performance cost. – dsz Jul 27 '17 at 10:28
8

I tried to do something, although it won't make much sense at least for , it's like VM inside VM, if it helps somebody

  1. Used Amazon EC2 account and installed free tier Windows Server 2012
  2. Took remote access to this so called VM, and install virtual box into it.
  3. Install a smallest possible Linux Headless (Slitaz) in this virtual box.

Here is how it looks,

enter image description here

Shrikant Havale
  • 1,102
  • 1
  • 13
  • 34
7

I haven't yet found an exceedingly "authoritative" source (e.g. explicit EC2 or VirtualBox documentation) but the answer definitely seems to be: No.

The best explanation I've found so far is in Running Hyper-V, VMware or Xen on an AWS EC2 Instance?: virtualization feels like emulation, as if Amazon is running a "CPU simulator app". But a hypervisor is more like a kernel: it claims certain privileges on the actual physical CPU, exclusively for itself. Just like a kernel prevents apps from using physical CPU features that would interfere with other apps, a hypervisor is something of a "superkernel" that prevents kernels from using physical CPU features that might interfere with other kernels.

Basically: Amazon's virtualization software is already using the privileged instruction sets that VirtualBox would need. You will have to either use an emulator as David suggests, or somehow convert your VirtualBox image into a format supported by Amazon's VM Import tool — essentially convert your VM to run directly as its own EC2 instance.

natevw
  • 13,661
  • 7
  • 58
  • 81
  • VB definitely runs on AWS – Shaun Neal Jan 22 '16 at 16:37
  • Can you provide any references with more details than that? I'm particularly curious whether it really virtualizes, or does it merely fall back to emulation in that case? Some of the other answers that are here now indicate the app might at least work from Windows instances, but is slow [indicating possibility of emulation…] – natevw Jan 22 '16 at 21:45
  • 1
    It's pretty easy to test - start up a t2.micro (for free) running Windows 2012R2 - download latest version of Virtualbox and install. It will only run 32 bit O/S. My implementation was to run freenas (which it did fine). It won't run 64 bit because the server is already virtual; I dont know what "emulation" means, but you can check it out pretty easily and for free to see if it will work for your needs. – Shaun Neal Jan 24 '16 at 19:02
4

I tried working with Virtual Box in Amazon EC2 today. Here is what I found

64 Bit VM's doesn't work at all. So you have to use only x86 VM in Virtual Box. You also have to limit CPU count per VM to 1. It doesn't work with 1+ CPU. You can modify it in vm_name.vbox file directly. Look for <CPU count="1" hotplug="false">

Note: Host OS on Virtual Box was "Ubuntu 14.04 x64" and guest OS was "Ubuntu 14.04 x64/x86" while testing

4

There were some new developments recently. Now AWS has bare metal boxes, which are not VMs, but actual physical boxes.

Unfortunately, because AWS hardware is super dense the smallest box you can get is m5d.metal, which is 96 core, 768GB monster which comes quite pricey. Also, it looks like there is no spot market for those either.

I just tried to spin up Ubuntu instance on m5d.metal box, installed Vagrant and VirtualBox and tried to run one of my Windows boxes. It worked as expected without any problems.

Vlad
  • 8,407
  • 4
  • 39
  • 60
  • AWS introduced a cheaper instance type a1.metal with 32GB RAM in Oct 2019. – bcoughlan Mar 18 '20 at 17:27
  • 1
    Unfortunately this one wouldn't work. A* machines are based on ARM CPU. VMs are not emulators, they can only run guest OS built for the same CPU architecture. – Vlad Mar 18 '20 at 20:29
3

I tried this today and definitive answer is: No.

You can install the GUI but kernel module will not install:

sudo /sbin/vboxconfig
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: Starting VirtualBox services.
vboxdrv.sh: failed: Running VirtualBox in a Xen environment is not supported.
Yekta Leblebici
  • 346
  • 1
  • 3
  • 11