projectz

Tech, Gadgets, Photography, Social Media and Poor Spelling

Question: Can I run a virtual machine in a virtual machine on Ubuntu?

Scope:

  • 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

Instructions

  1. Install the latest virtualbox from the virtualbox.org site NOT from the ubuntu packages (the ubuntu is outdated) dpkg -i <virtualbox deb file>
  2. Create the new virtual machine: VBoxManage createvm —name “ubuntuserver1004” —ostype Ubuntu —register
  3. Setup the base machine: VBoxManage modifyvm “ubuntuserver1004” —memory 256 —acpi on —nic1 bridged
  4. Setup the IDE Controller: VBoxManage storagectl “ubuntuserver1004” —name “IDE Controller” —add ide —controller PIIX4
  5. 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

[1] 28323

root@testmail:/opt/vbox# Oracle VM VirtualBox Headless Interface 4.1.6

(C) 2008-2011 Oracle Corporation

All rights reserved.

Notes:

  • 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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on November 9, 2011 by in regular and tagged , , , , , .
%d bloggers like this: