VirtualBox: Sharing folders between host and guest

Recently, having finally refused to surrender to windows, I installed Ubuntu virtualised as a guest on Windows as a host using Oracle’s recently released VirtualBox. Here’s a tip on how to share folders between guest and host in the official way.

On the guest VM virtualbox menu open ‘Shared folders’.

Open Shared Folders
Open Shared Folders

On the top right of the dialogue box that comes up click the ‘+’ icon. Fill in the dialogue by adding a name and location.

Add share
Add share

After that you should have a shares dialogue as below.

Shares Dialogue
Shares Dialogue

Next, as root, mount manually.

mkdir /mnt/share
mount -t vboxsf virtual-box-ubuntu-share /mnt/share/

And, finally, add the following entry into /etc/fstab for future boots.

virtual-box-ubuntu-share /mnt/share vboxsf defaults 0 0

Done. Ubuntu on VirtualBox running as guest on a Windows host is by far the best and most compelling complement to your development environment if you are forced into using Windows as a host. VirtualBox even supports seamless mode which means that you can have Linux and Windows windows intermingled on the windows desktop. Superb. And best of all – both VirtualBox and Ubuntu being completely free.

Update: Great news. VirtualBox 4.0 is out. Here’s what’s new.

Advertisements

Installing Java, Scala and Vim support on Linux

Here’s a quick guide on how to install Scala on linux (in my case Ubuntu 9.04). A prerequisite obviously is to have the sun jdk installed and properly integrated into your linux environment. For completeness I detail how I normally tend to set up the jdk on my linux environment before moving onto the installation of Scala. Note that here /opt/ is used as the destination directory for installation as that is what I prefer but this can be any directory that you have write permissions on. You’ll also note that I don’t use any automated linux installation tool like apt-get and that is deliberate as the following methods of installation allow you not only complete control of installation of the packages but greater flexibility when upgrading. Finally we’ll look at adding Scala support to my favourite command line editor – Vim.

Install Sun JDK

Download the latest Sun JDK (JDK 6 Update 14 at time of writing).

Make executable and extract.

$ chmod u+x jdk-6u14-linux-i586.bin
$ ./jdk-6u14-linux-i586.bin

Relocate.

$ mv jdk1.6.0_14/ /opt/

Symlink.

$ cd /opt/
$ ln -s jdk1.6.0_14/ java

In /etc/profile set JAVA_HOME variable and add JDK bin directory to system path.

export JAVA_HOME="/opt/java"
export PATH="${JAVA_HOME}/bin:${PATH}"

Import your newly modified profile

$ source /etc/profile

Test Java.

$ java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Server VM (build 14.0-b16, mixed mode)
$ javac -version
javac 1.6.0_14

Install Scala

Download the latest Scala (2.7.5 at time of writing).

Extract.

$ tar -xvzf scala-2.7.5.final.tgz

Move.

$ mv scala-2.7.5.final/ /opt/

Symlink.

$ cd /opt/
$ ln -s scala-2.7.5.final/ scala

In /etc/profile set SCALA_HOME environment variable and add the Scala bin directory to your system path.

export SCALA_HOME="/opt/scala"
export PATH="${SCALA_HOME}/bin:${JAVA_HOME}/bin:${PATH}"

Import your newly modified profile

$ source /etc/profile

Test Scala.

$ scala
Welcome to Scala version 2.7.5.final (Java HotSpot(TM) Server VM, Java 1.6.0_14).
Type in expressions to have them evaluated.
Type :help for more information.

scala> 1+1
res0: Int = 2

scala> println("Hello World!")
Hello World!

Add Scala support into Vim

If you’re like me and you can’t live without Vim or you just need Vim to get started with Scala prior to moving onto your favourite IDE then here’s how you can add Scala support into Vim.

Create required vim directories.

$ mkdir -pv ~/.vim/ftdetect
$ mkdir -pv ~/.vim/indent
$ mkdir -pv ~/.vim/syntax

Download Scala support into vim directories.

$ wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/export/18260/scala-tool-support/trunk/src/vim/ftdetect/scala.vim -O ~/.vim/ftdetect/scala.vim
$ wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/export/18260/scala-tool-support/trunk/src/vim/indent/scala.vim -O ~/.vim/indent/scala.vim
$ wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/export/18260/scala-tool-support/trunk/src/vim/syntax/scala.vim -O ~/.vim/syntax/scala.vim

Create a basic ~/.vimrc configuration if you haven’t got one.

set nocompatible
set nu
syntax on
filetype indent on
set autoindent
set ic
set hls
set lbr
colorscheme delek

Try editing a Scala file. It should appear in colour.

1 for {i <- 1 to 10
2 j <- 1 to 10}
3 println(i*j)

Rejoice. Get coffee. Develop. Lose sleep. The usual lifecycle.

Acknowledgements (Scala Vim support, Vim colorised output).

K(u)buntu 8.10 released

I’m a little late in reporting this but on 30 Oct (3 days ago) Ubuntu and Kubuntu 8.10 were released. Currently I use Debian for server and Kubuntu for desktop. Previously I was a big fan of Gentoo and prior to that I tried every distribution under the sun while at university. Kubuntu 8.10, it seems, includes KDE4 which I really hope has stabilised sufficiently to become the default distributed version and reached the 4.1 version. The last remix cd was, from what I’ve heard, unusable.

While previously Ubuntu was a little new on the scene and was being treated with skepticism as yet another operating system based on Debian it has now matured into a stable, trusted and widely adopted linux distribution and for me, as with most people, it simply works and stays out of the way allowing me to get my work done – the work being in my case not only being my primary operating system but also being my preferred environment for Java development. A dual boot between Vista and Linux is of course always necessary – Windows being for games, IE and other Windows specific requirements.