Can VirtualBox be executed under Amazon EC2 instance?
Asked Answered
B

10

39

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?

Brayer answered 29/9, 2011 at 18:37 Comment(3)
Virtualized virtualizations.... ouch.Anecdotage
you might want to check this articleRohn
@Ella: Excellent link! Too bad lxc-checkpoint is not implemented yet, so LXC has no snapshots yet. But I will keep an eye on this project.Brayer
B
24

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.

Brayer answered 31/1, 2013 at 1:55 Comment(4)
seem that it does not support Virtualbox vmdk file. None of the docs on AWS mentions Virtualbox: docs.aws.amazon.com/AWSEC2/latest/UserGuide/…Howrah
There is a need: B/SaaS applications might want tons of ultra small machines - 1 per user.Energy
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 supportedBennett
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.Stogner
P
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.

Pomander answered 29/9, 2011 at 18:51 Comment(1)
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 resourcesMagenta
U
10

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.

Uncouth answered 4/7, 2012 at 9:31 Comment(2)
could you provide a guide on how to do that in amazon linux?Maidenhead
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.Dabble
G
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

Greegree answered 21/3, 2015 at 11:21 Comment(1)
could you provide a guide on how to do that in amazon linux?Maidenhead
T
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.

Tuff answered 8/3, 2012 at 21:3 Comment(3)
VB definitely runs on AWSPhosphorescent
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…]Tuff
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.Phosphorescent
V
5

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

Villada answered 15/3, 2016 at 22:4 Comment(0)
T
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.

Templia answered 17/5, 2019 at 0:46 Comment(2)
AWS introduced a cheaper instance type a1.metal with 32GB RAM in Oct 2019.Tawnyatawsha
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.Templia
J
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.
Joule answered 28/11, 2017 at 11:11 Comment(0)
S
3

All AWS instances including the bare-metal ones already run in a virtualized environment.

Running VirtualBox in an EC2 instance means you want to run another virtual environment inside an already existing virtual environment called nested virtualization.

AWS has provided special instance types named bare-metal(.metal) instances to support nested virtualization.

So, for VirtualBox, Hyper-V, or any other virtual environment in an EC2 instance, use any of the available bare-metal instances. They are very costly though.

Syntactics answered 24/6, 2022 at 10:49 Comment(0)
D
1

For those who are interested in seeing how "nested virtualiztion" works on bare metal EC2 instances:

# curl -w "\n" 169.254.169.254/latest/meta-data/instance-type
c5n.metal

# cat /etc/issue
Ubuntu 20.04.3 LTS \n \l

# dpkg -l virtualbox
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version                       Architecture Description
+++-==============-=============================-============-===========================================
ii  virtualbox     6.1.26-dfsg-3~ubuntu1.20.04.2 amd64        x86 virtualization solution - base binaries

# VBoxManage list vms
"vagrant-project1_vm1_CentOS_1643693775729_39367" {d5043860-dcb6-4d05-a5be-a528b28cddf9}
"vagrant-project1_vm2_Ubuntu_1643693811420_34650" {3534a74d-a52b-4c2f-84bf-404ce524018d}

# vagrant status
Current machine states:

vm1_CentOS                running (virtualbox)
vm2_Ubuntu                running (virtualbox)

# vagrant ssh vm2_Ubuntu --command  "sudo virt-what"
virtualbox

The last command above shows the virtulization type of the nested VM is "virtualbox".

Disrobe answered 1/2, 2022 at 10:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.