Setup – Ubuntu


This is a quick and easy tutorial to get up and running quickly with a complete environment as set out below.  Before we start I feel I need to share my personal setup…

I’m currently running a Windows 7 machine on my home PC with 8GB of RAM, a Intel i5 760 Chip and some other cool goodies.  The only reason I mention this is because I’m not sure whether this all will work quite as seamlessly on someone else’s machine, but it should because as part of this setup is the complete environment running on a Ubuntu VirtualBox VM.

What will be covered is how to easily get up and running in the quickest, easiest manner.  What I’ll be going through are as follows:

  1. Installing a Ubuntu Virtual Box VM
  2. Mounting a Shared Folder
  3. Port Forwarding
  4. Running VirtualBox in Headless Mode
  5. Changing a Ubuntu Machine Name

Installing a Ubuntu Virtual Box VM

So to get this step done you’ll have to head over to the VirtualBox download site and download the latest version.  The version that I’m using in this article is version 3.2.10 for Windows hosts.  While that’s busy downloading you can start the download of the Ubuntu ISO as well by going to their download site.  The release that I’ve got is the 10.10 stable releases.

The reason I’m using these installs is because they are my personal preferences when working with Ubuntu and Virtual Software.  There are a few others that you can use and the steps should stay more or less the same, but I’ve found both these products to be easy to use and very stable and clean.

When you’re done downloading VirtualBox you can go through the steps of creating a new Virtual Machine by clicking on the “New” button.  In my install I used the following settings:

Name:                  Ubuntu-VM-Base
OS Type:              Linux
Version:               Ubuntu
Memory:             1024
Harddisk Settings:
Dynamicaly expanding

Once you’ve created your new VM you can change a few settings by right clicking on it and clicking on the “Settings” menu.   In the settings Dialog I usually change the following sections:

Leave as default

Leave as default

Video Memory:                32MB
Enable 3D Acceleration

Leave as default

Leave as default

Adapter 1:                           Should be NAT (Leave as Default)
Adapter 2:                           Enable Network Adapter – Set to Host-only Adapter

Leave as default

Shared Folders
Leave as default

Now that you have a VM and all your settings are set you should start it by clicking on the “Start” button.  When the VM starts it will start up the “First Run Wizard”.  When you click next, you’ll be presented by a dropdown box for Media Source with a folder icon next to it.  When you click on the folder you’ll be presented by the “Virtual Media Manager” where you can click on the “Add” button which will allow you to browse your newly downloaded Ubuntu iso file.  In my case the file’s name is:  ubuntu-10.10-desktop-amd64.iso.  When you select it, the window will close and take you back to the “Virtual Media Manager” where you should see your iso under the “Name” column.  Select it and click on the “Select” button, which should take you back to the “First Run Wizard”.  Click the finish button and you’ll be presented with a list of languages and when you select your language it will give you an option to run the “demo” or to install it.  Select the “Install” option and follow the steps.

Phew, those were a lot of words…  I hope you could follow so far, but it should be fairly straight forward and you should have your install up and running soon enough…

Once Ubuntu has finished installing it will state that it needs to restart.  When you click on “Restart Now” it will ask you to remove the remove the disk.  You should go to  the “Devices” menu and under the “CD\DVD Devices” submenu you’ll see your Ubuntu ISO checked.  Uncheck this.  Press to continue and you’ll be taken to the login screen where you can log in.   Then go to the Devices menu again and click on “Install Guest Additions” which will mount the Guest Additions ISO which will present you with an “Autorun Detected” screen.  Click on “Allow to run” and follow the steps…

If you are presented some text in a white screen that says something to do with “Your system does not seem to be set up to build kernel modules” don’t worry.  Open up the “File Manager” by clicking on the “Places/File System” menu.  Once open, go to the “VBOBADDITIONS_*” item on the left pane and copy the “” file.  I usually copy this to the folder “/Downloads” folder.  Once this is done open up a Terminal Window by right clicking on the right hand pane and selecting “Open Terminal Here” context menu.  When the Terminal Window opens, you can type in the following command:

sudo apt-get install dkms gcc

Once these packages are installed you should also run this command to download and install the Kernel Headers and the Linux distribution.

sudo apt-get install linux-headers-$(uname –r)

On completion of these installs you can type in the following command to make the file you copied and executable:

sudo chmod +x

Once done you can execute it by simply typing:

sudo ./

This should install the VirtualBox guest additions which will do quite a few things for you, which I’m not going to cover in this article.  If by chance you have my luck and it still doesn’t want to install, then reboot your VM.

Now you have a VirtualBox running with Ubuntu on it and you also have all the Guest Additions and after a quick reboot you’ll be ready to get into the nitty gritty of things more fun J

Mounting a Shared Folder

If you go to your “Devices/Shared Folders” menu item on your VirtualBox menu it will open a “Shared Folders” dialog.  In that dialog you’ll be able to add Shared Folders that maps a folder between your host and your VM.  To get this to work you’ll have to run the following command from a Terminal window inside your new Ubuntu VM:

sudo mount -t vboxsf

As an example I created the following folder on my VM:


I added the HostShare Shared Folder under the “Shared Folders” dialog which maps to:


I then ran the following command to mount the shared folder:

sudo mount -t vboxsf /home/jaco/HostShare/ HostShare

Once run it will mount the folder for this session and it will allow you to copy files to and from your host.  If you would like to make this a permanent thing you can add the above line to the “/etc/rc.local” file and your Ubuntu environment will run it every time you start it up.  This caused me some interesting reading through some forums only to realize that the very first forum I went to had the answer J

Port Forwarding

Now that you have your environment set up, I’m sure you would like to set up Port Forwarding so that whenever a specific port gets accessed on your Host machine it will redirect the calls and requests to the specified guest Ubuntu environment.  This will then allow you to putty into your Ubuntu environment which will allow you to run your Ubuntu environment in “headless” mode, meaning now open windows.  In my case I have a Hudson environment that I want to access without actually having to go into my VirtualBox.  I just want it to run silently in the background and when I browse to it through my host, it will then automatically be serving up the pages in my Continuous Integration environment…

This is made really easy in VirtualBox.  So, open and Command Prompt window on your host and browse to your Ubuntu installation folder.  The default on my machine was at: “c:\Program Files\Oracle\VirtualBox”.  Once you’re there run the following commands.

To setup your Host Port which will be forwarded do as follows:

VBoxManage setextradata VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/HostPort 2222

To set up your guest port on which your host will communicate to your guest:

VBoxManage setextradata VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/GuestPort 22

To set up the communications protocol that you will be using:

VBoxManage setextradata VBoxInternal/Devices/e1000/0/LUN#0/Config/ssh/Protocol TCP

Reboot your Ubuntu guest and you should now be able to putty into it without any hassles…

Running VirtualBox in Headless mode

Running your VirtualBox VM in headless mode is probably one of the easier things to do.  To do this all you have to do on your Host machine is open a Command Prompt window, browse to the VirtualBox installation folder (“c:\Program Files\Oracle\VirtualBox” on my machine) and run the following command:

VBoxManage startvm –type headless

To stop the VM while saving state you can simply run the following command:

VBoxManage controlvm startvm savestate

Changing an Ubuntu machines name

Open a Terminal Window in your Ubuntu environment and then type in the following command:

sudo gedit /etc/hosts

This will ask you for your administrator password and will then open the “hosts” file in gedit.  Change the second line in this file usually in the format of:              <Your Old Machine Name>

To show as follows:              <Your New Machine Name>

Once this is done close the gedit window and run the following command:

sudo gedit /etc/hostname

This will ask you for your administrator password and will then open your “host” file.  In your host file you can then change the machine name and save it.  Close all windows and restart your Ubuntu machine.


I hope you have as much fun with Ubuntu as I’m having.  I’m finding it to be an extremely powerful platform and even though it can be tricky when you go into the more advanced topics, I do have to say that it’s a fun environment to work on and it is stable.

As I come across more tools and cool toys to work with I’ll be updating this page and site.  I’m hoping to use this site and all the articles as reference point for myself and are hoping that it will also help someone else out there.  I found it quite daunting and confusing when I started dabbling with these technologies, but as time goes by and my collection of references goes by, I’m getting more and more comfortable and finding it harder and harder to switch back to my Windows environment.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

You are commenting using your 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

%d bloggers like this: