Question: Can I run a virtual machine in a virtual machine on Ubuntu?
- Ubuntu 11.10 running on VMware fully patched.
- for the cope of the document i created ubuntu.vdi file on a local machine and used sftp to upload it to the VMware server
- on the ubuntu.vdi, normally when you migrate a machine, the eth0 will turn into eth1 as the mac address will change. To get around this type: sudo rm /etc/udev/rules.d/70-persistent-net.rules udev will respawn the file on the next reboot.
- vdi located in /opt/vbox
- Install the latest virtualbox from the virtualbox.org site NOT from the ubuntu packages (the ubuntu is outdated) dpkg -i <virtualbox deb file>
- Create the new virtual machine: VBoxManage createvm —name “ubuntuserver1004” —ostype Ubuntu —register
- Setup the base machine: VBoxManage modifyvm “ubuntuserver1004” —memory 256 —acpi on —nic1 bridged
- Setup the IDE Controller: VBoxManage storagectl “ubuntuserver1004” —name “IDE Controller” —add ide —controller PIIX4
- Add the VDI which was uploaded earlier to the machine: VBoxManage storageattach “ubuntuserver1004” —storagectl “IDE Controller” —port 0 —device 0 —type hdd —medium “/opt/vbos/ubuntu.vdi”
Most instructions on the web at this point tell you that its possible to start the VM Now, however we have chosen to use bridged networking, not NAT, so the VM will fail with various surious errors complanining about host networking now. To fix these:
First check that the Bridged interface has been setup
VBoxManage list bridgedifs
should come back withName: eth0GUID: 30687465-0000-4000-8000-000c2920a3c1Dhcp: DisabledIPAddress: 192.168.20.33NetworkMask: 255.255.255.0IPV6Address: fe80:0000:0000:0000:020c:29ff:fe20:a3c1IPV6NetworkMaskPrefixLength: 64HardwareAddress: 00:0c:29:20:a3:c1MediumType: EthernetStatus: UpVBoxNetworkName: HostInterfaceNetworking-eth0
We now need to link the bridge adaptor to the correct ethernet port.
vboxmanage modifyvm ubuntuserver1004 —bridgeadapter1 eth0
Now we are ready to start the vm:
VBoxHeadless —startvm ubuntuserver1004 &
If all is good, you should see this
root@testmail:/opt/vbox# Oracle VM VirtualBox Headless Interface 4.1.6
(C) 2008-2011 Oracle Corporation
All rights reserved.
- you do not need to specify —ostype, but doing so selects some sane default values for certain VM parameters, for example the RAM size and the type of the virtual network device. To get a complete list of supported operating systems you can use VBoxManage list ostypes