Here's my situation: Ubuntu 9.04 server, headless and I want to install Virtualbox on it and get Ubuntu 8.04 LTS servers running as root.
Step 1: Install VirtualboxFollowing the directions at the
Virtualbox Linux download page I did the following:
1a) Edited /etc/apt/sources.list and add the virtual box repository:
deb http://download.virtualbox.org/virtualbox/debian jaunty non-free
1b) Add the virtualbox key to the apt keyring:
wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.asc -O- | sudo apt-key add -
1c) And install:
apt-get install virtualbox-2.2
Step2: Configured bridged networkingI basically followed the directions on the
help.ubuntu.com wiki.:
2a) Install bridge-utils:
apt-get install bridge-utils
2b) Now edit /etc/network/interfaces and add the br0 interface with the same address as your primary interface (eth0 in my case). Note that these directions assume you are using a static IP, if not you are on your own. My /etc/network/interfaces now looks like this:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
# Configured per https://help.ubuntu.com/community/VirtualBox/Networking
# Address of br0 should be the same as eth0
auto br0
iface br0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
bridge_ports eth0 vbox0 vbox1
2c) Now restart the networking:
/etc/init.d/networking restart
...wait a couple minutes for the network to come back - my SSH session survived the restart YMMV...
Now I have a br0 interface:
# ifconfig br0
br0 Link encap:Ethernet HWaddr 00:18:8b:76:32:11
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::218:8bff:fe76:3211/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:87 errors:0 dropped:0 overruns:0 frame:0
TX packets:74 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6130 (6.1 KB) TX bytes:11447 (11.4 KB)
2d) Create /etc/vbox/interfaces:
vi /etc/vbox/interfaces
So that it looks like:
vbox root br0
2e) Restart virtualbox networking, but hmmm, I don't have /etc/init.d/vboxnet, but I do have /etc/init.d/vboxdrv so I restarted that instead:
/etc/init.d/vboxdrv restart
2f) I skipped setting permissions on /dev/net/tun since I'm running VMs as root.
Step 3: Create a VMI basically followed
these directions, updated as I went. Also kudos to
Sasquatch for the nic1 and bridgeadapter1 options.
3a) Create the new VM. You should be able to set the memory as you see fit. Other options you probably don't want to mess with.
VBoxManage -q createvm -name Ubuntu-Server -register
VBoxManage -q modifyvm Ubuntu-Server -memory 384MB -acpi on -ostype ubuntu -pae on -nic1 bridged -bridgeadapter1 br0
Note that if you have other VMs using vrdp you probably want to add "-vrdpport
#" to use an available port (default port is 3389).
3b) Create disk for the new VM and attach it. I created an 8GB disk based on
my experiences trying to use smaller disks.
VBoxManage -q createhd -filename "Ubuntu-Server.dvi" -size 8192 -register
VBoxManage -q modifyvm Ubuntu-Server -hda Ubuntu-Server.dvi
3c) Download the iso for 8.04 server from
Ubuntu. Note I use 8.04 since it has long-term support and hence I won't have to worry about upgraded the OS on the VM as often. Note that while the Ubuntu page tried to get me to use the 64 bit version, I found it did not work for me (I got the following error trying to boot with it: "This kernel requires an x86-64 CPU, but only detected an i686 CPU. Unable to boot - please use a kernel appropriate for your CPU.") so I used the 32 bit version instead. You should also choose a copy from a local mirror.
wget http://osmirrors.cerias.purdue.edu/pub/ubuntu-releases/hardy/ubuntu-8.04.2-server-i386.iso
3d) Register the iso image and attach it to the VM:
VBoxManage -q registerimage dvd /path/to/ubuntu-8.04.2-server-i386.iso
VBoxManage -q modifyvm Ubuntu-Server -dvd /path/to/ubuntu-8.04.2-server-i386.iso
Ok, we now have a VM that's ready to boot and install Ubuntu...
Step 4: Start the VM and Connect to it via vrdp4a) Start the VM in
vrdp mode:
VBoxManage -q startvm Ubuntu-Server --type vrdp
4b) Connect using a remote desktop client. What I found worked for me from my Ubuntu 9.04 laptop was 'rdesktop' from the commandline:
rdesktop server-name
Or from my Mac,
Remote Desktop Connection, though it does give a warning about "Remote Desktop Connection cannot verify the identity of the computer that you want to connect to."
Step 5: Do a standard Ubuntu InstallOk, you should now be looking at the console on the VM which has booted from the CD. Go ahead and do your standard Ubuntu install.
When the install completed, I found the system automatically rebooted from the hard drive without me having to do anything to unmount iso image.
Step 6: Clean upThe only thing to do is detact the iso from the VM. After powering off the VM, do the following:
VBoxManage -q modifyvm Ubuntu-Server -dvd none