Run VirtualBox on Ubuntu 14.04 Cloud Server Instance – Yeah, Virtualization within Virtualization! It is actually possible to install and run. When we run virtual machines with VirtualBox on computer, normally we use the VirtualBox GUI to manage the virtual machines – like we shown in the guide to run Ubuntu on MacBook Pro. but a server does not have a desktop environment unless we specifically prepare it for using as VNC. VNC setup is not required to run VirtualBox on Ubuntu 14.04 Cloud Server Instance. VirtualBox has a tool called VBoxHeadless that basically allows you to connect to the virtual machines over a remote desktop connection, so the GUI is not required.
Run VirtualBox on Ubuntu 14.04 Cloud Server Instance : Initial Steps
You can open an account on DigitalOcean using this link, if you have a Credit Card and no Account on DigitalOcean. You’ll get $10 account credit plus you can add any coupon (if applicable) to increase your account’s credit. Enough to test our guides free of cost.
We are taking that you are using either DigitalOcean or Rackspace Cloud or HP Cloud to test. For HP Cloud, you need to set Ingress-Egress policy. HP Cloud is a bit hard and great to learn networking and OpenStack.
---
Spin a 4GB instance with Ubuntu 14.04 LTS image. First SSH to the instance :
1 2 3 4 5 6 7 8 9 10 11 12 13 | ssh root@IP-Address ##The authenticity of host '127.0.0.1' can't be established. ##ECDSA key fingerprint is ################ ##Are you sure you want to continue connecting (yes/no)? # type yes and hit the return key # you will have the password, use it and change it # upgrade and update apt-get update -y && apt-get upgrade # do a dist-upgrade apt-get diet-upgrade -y # reboot and login again ssh root@IP-Address |
Ubuntu 14.04 is named trusty
, open your /etc/apt/sources.list
:
1 | nano /etc/apt/sources.list |
Add this line :
1 | deb http://download.virtualbox.org/virtualbox/debian trusty contrib |
Download the Public Key and update apt :
1 2 | wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add - apt-get update -y |
Run VirtualBox on Ubuntu 14.04 Cloud Server Instance : Main Steps
Run this :
1 | apt-get install dkms unzip linux-headers-$(uname -r) build-essential virtualbox-4.3 -y |
That dkms
is an important thing. Run this :
1 2 | cd /opt wget http://download.virtualbox.org/virtualbox/4.3.14/Oracle_VM_VirtualBox_Extension_Pack-4.3.14-95030.vbox-extpack |
We got the link from here :
1 | https://www.virtualbox.org/wiki/Downloads |
Run this command with sudo
:
1 | sudo VBoxManage ext pack install Oracle_VM_VirtualBox_Extension_Pack-4.3.10-93012.vbox-extpack |
You should create users other than root. Take that you have created a user named abhishek
, then run this :
1 | sudo adduser abhishek vboxusers |
You can set password in this way :
1 | sudo passwd vbox |
VirtualBox is now installed and ready to be used. VBoxManage
brings the interactive mode. Like running :
1 | VBoxManage --help |
will show you the commands.
Run VirtualBox on Ubuntu 14.04 Cloud Server Instance : Optionally Adding a Web Interface
Adding a Web Interface to run VirtualBox on Ubuntu 14.04 Cloud Server is optional. We will run Apache2 web server and install the PHP components for it :
1 2 3 4 5 6 7 8 9 10 11 12 13 | apt-get install apache2 php5 libapache2-mod-php5 php-soap -y && service apache2 restart cd /opt && rm -r wget 'http://downloads.sourceforge.net/project/phpvirtualbox/phpvirtualbox-4.3-1.zip' -O phpvirtualbox.zip unzip phpvirtualbox.zip mv phpvirtualbox-4.3-1 /var/www/html/phpvirtualbox mv /var/www/html/phpvirtualbox/config.php-example /var/www/html/phpvirtualbox/config.php nano /var/www/html/phpvirtualbox/config.php # this are instructions # That $username and $password should match the user you created nano /etc/default/virtualbox # make sure you have this line : # Add VBOXWEB_USER=vbox sudo /etc/init.d/vboxweb-service start |
In a browser, i you point go to http://your-IP/phpvirtualbox
and login with username ‘admin’ and password ‘admin’. You should change it after login into phpvirtualbox.
These are optional steps.
Run VirtualBox on Ubuntu 14.04 Cloud Server Instance : Managing Virtual Machines From SSH
If we do not use the Web Interface, we still can use VirtualBox to create instance, import and run ISO. All guides are written on :
1 2 | http://www.virtualbox.org/manual/ch08.html http://www.virtualbox.org/manual/ch07.html#vboxheadless |
Another important part is VirtualBox networking setting, you need to select bridged
rather than the default of NAT
. By default, VirtualBox VMs will present the guest operating system with a networking setup that works well enough for a web browser.
Selecting this bridged
networking makes the virtual machine to appear as if it is simply another computer attached to your network via an Ethernet cable. That is separate story though. This way, we found even easier than container based virtualization.
Run VirtualBox on Ubuntu 12.04 Cloud Server Instance : HP Cloud
Another way we found probably work on HP Cloud Only. Notice that, this is for Ubuntu 12.04
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | ## Install necessary packages apt-get install virtualbox-ose qemu-utils genisoimage cloud-utils ## kvm unloaded modprobe -r kvm_amd kvm_intel service virtualbox stop service virtualbox start ## cloud image of 12.04 img_url="http://cloud-images.ubuntu.com/server/releases/12.04/release" img_url="${img_url}/ubuntu-12.04-server-cloudimg-amd64-disk1.img" ## cloud-localds is not in archive localds_url="http://bazaar.launchpad.net/~cloud-utils-dev/cloud-utils/trunk/download/head:/cloudlocalds-20120823015036-zkgo0cswqhhvener-1/cloud-localds" which cloud-localds || { sudo wget "$localds_url" -O /usr/local/bin/cloud-localds && sudo chmod 755 /usr/local/bin/cloud-localds; } ## download a cloud image to run img_dist="${img_url##*/}" img_raw="${img_dist%.img}.raw" my_disk1="my-disk1.vdi" wget $img_url -O "$img_dist" qemu-img convert -O raw "${img_dist}" "${img_raw}" vboxmanage convertfromraw "$img_raw" "$my_disk1" ## create user-data seed_iso="my-seed.iso" cat > my-user-data <<EOF ##cloud-config password: passw0rd chpasswd: { expire: False } ssh_pwauth: True EOF cloud-localds "$seed_iso" my-user-data ## create a virtual machine using vboxmanage vmname="precise-nocloud-1" vboxmanage createvm --name "$vmname" --register vboxmanage modifyvm "$vmname" \ --memory 512 --boot1 disk --acpi on \ --nic1 nat --natpf1 "guestssh,tcp,,2222,,22" # Another option for networking --nic1 bridged --bridgeadapter1 eth0 vboxmanage storagectl "$vmname" --name "IDE_0" --add ide vboxmanage storageattach "$vmname" \ --storagectl "IDE_0" --port 0 --device 0 \ --type hdd --medium "$my_disk1" vboxmanage storageattach "$vmname" \ --storagectl "IDE_0" --port 1 --device 0 \ --type dvddrive --medium "$seed_iso" vboxmanage modifyvm "$vmname" \ --uart1 0x3F8 4 --uartmode1 server my.ttyS0 ## start VM vboxheadless --vnc --startvm "$vmname" ## connect to the vnc port that vboxheadless ## showed was used. The default would be '5900', after the system boots, you can ssh in with 'ubuntu:passw0rd' ## via 'ssh -p 2222 ubuntu@localhost' ## To see where kernel output goes, you ## can use 'socat', like this: socat UNIX:my.socket - ## poweroff vboxmanage controlvm "$vmname" poweroff ## clean up vboxmanage storageattach "$vmname" \ --storagectl "IDE_0" --port 0 --device 0 --medium none vboxmanage storageattach "$vmname" \ --storagectl "IDE_0" --port 1 --device 0 --medium none vboxmanage closemedium dvd "${seed_iso}" vboxmanage closemedium disk "${my_disk1}" vboxmanage unregistervm $vmname --delete |
You should read the Ingress-Egress for HP Cloud.
Tagged With Ubuntu10 04下运行VirtualBox显示非致命性错误 , cloud computing virtualbox role , cloud sync virtualbox , how to install virtualbox on ubuntu instance? , oracle cloud ubuntu установка virtualbox , run virtual box from a cloud , run virtualbox in cloud , virtual box running on ubuntu server , virtualbox open cloud instance