I have been running virtualbox for over ten years and I have been running a headless server with virtualbox headless (no GUI) for 5 years. I seem to always run into issues were I am making new a machine and need to remember how to do everything. This is my current situation, I have a live server were I host an email server, web server, davical server, vtiger server all on VirtualBox servers. I am now upgrading to new hardware and I needed to re-learn all of this again, so I am making a tutorial for others in this situation so you don’t need to spend an exuberant amount of time hunting this information down.
So hopefully this is as complete and clear as possible. Ok lets start with installing Virtualbox without the GUI. This is assuming you are running Ubnuntu Server 12.04 (should work on most current versions (has no GUI)) (Side Note I do install as root, if you prefer not to switch to root make sure you use sudo in front of the commands)
Install Ubuntu Server
Setup to taste make sure you install SSH and Virtual Machine Host
If you need help installing and configuring PM me and I will help you.
I would make a tutorial on how to install Ubuntu 12.04 Server with a RAID1configuration, but this is a Virtualbox forum and not a Ubuntu Linux Forum.
Update the Server
# apt-get update && apt-get upgrade
Install Virtualbox
Edit the sources list file
# nano /etc/apt/sources.list
Add the following line to the end of the file
deb http://download.virtualbox.org/virtualbox/debian precise contrib
Install Oracles Key
# wget -q download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add –
# apt-get update
# apt-get install linux-headers-$(uname -r) build-essential dkms virtualbox-4.3
Install Vbox Extension Pack
# wget download.virtualbox.org/virtualbox/4.3.8/Oracle_VM_VirtualBox_Extension_Pack-4.3.8-92456.vbox-extpack
# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.8-92456.vbox-extpack
Now Lets Install Webmin
# wget prdownloads.sourceforge.net/webadmin/webmin_1.670_all.deb
# dpkg –install webmin_1.670_all.deb
# apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python
# apt-get -f install
Install htop (optional)
# sudo apt-get install htop
(this is top on steriods)
Create Virtual Machine
Creating the virtual machine is done under the user who will be managing them hence $ and not #
The settings below should work in most modern machines, however I suggest you read the documentation on the commands below to understand what they are doing.
WebServer name is being used in this case but that name should be changed to your server name.
##
## Create the Virtual Machine and register it
##
(side note here: I am using a different directory for my virtual machines () instead of keeping them in my home directory this is not necessary)
$ VBoxManage createvm –basefolder /VMF –name WebServer –register
##
## Create the Attributes of the Virtual Machine (Note the first 4 options are for multiple cpu’s or cores.)
##
$ VBoxManage modifyvm “WebServer” –hwvirtex on –pae on –ioapic on –cpus 2 –memory 2024 –acpi on –boot1 dvd –nic1 bridged –bridgeadapter1 eth0 –ostype Ubuntu_64
##
## Create the Virtual Machine Hard Drive The size is in MB and should be changed to what is needed
## or can be used. (The command below will create a 500GB Virtual Hard Drive)
$ VBoxManage createhd –filename /VMF/WebServer/WebServer.vdi –size 500000 –format VDI
##
## Establish Controller
##
$ VBoxManage storagectl “WebServer” –name “SATA Controller” –add sata –controller IntelAhci –bootable on
##
## Connect the storage devices to the controller
##
##
## Hard Drive Storage
##
$ VBoxManage storageattach “WebServer” –storagectl “SATA Controller” –port 0 –device 0 –type hdd –medium /VMF/WebServer/WebServer.vdi
##
## DVD Drive Storage
##
$ VBoxManage storageattach “WebServer” –storagectl “SATA Controller” –port 1 –device 0 –type dvddrive –medium host:/dev/sr0 –passthrough on
##
## Start the VM and have it run in the background.
##
$ VBoxHeadless –startvm “WebServer” &
That’s all.