开发者

Can VirtualBox be executed under Amazon EC2 instance?

开发者 https://www.devze.com 2023-04-09 16:10 出处:网络
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.

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?


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.


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.


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.


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,

Can VirtualBox be executed under Amazon EC2 instance?


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.


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


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.


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.


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.


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".

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号