Lubuntu 12.10 Virtual Box Setup

Introduction

This post represents a foray into a new field for me- virtualization. Although I have run virtual machines off and on for various purposes over the past couple years, I never put the time into learning how to get one configured exactly to my liking- any inconveniences I experienced I simply put up with.

A bit ago I downloaded the latest version of Lubuntu, which at the time of this writing is 12.10. I was immediately impressed with how well the distro looked and performed. I decided this would make an ideal candidate for a virtual machine dedicated to a bit of web surfing, coding, and IRC. My host is Windows 7.

Although my other machines run Crunchbang, I prefer a traditional menu for virtual machines. LXDE seemed an obvious choice; simple and easy to use and light enough to run speedily in a limited virtual environment.

My previous VMs ran a mixture of standard Ubuntu and LXDE, as I needed some features vanilla Ubuntu offered. However I believe the VM suffered a fairly substantial speed loss when dealing with all the features of vanilla Ubuntu, especially as I rarely give my machines more than 2 GB RAM.

This post will recount my steps in creating a Lubuntu 12.10 virtual machine with capabilities including:

Bidirectional copy/paste between VM and host

Shared folder for file transfer between VM and host

Ability to resize VM screen

I will be using Oracle’s VirtualBox, which is by far the most commonly available virtualization software available for all platforms.

All the features outlined above come with the Guest Additions package that you can install via VirtualBox. However Lubuntu is missing several key elements to its installation. This article will deal primarily with getting the guest additions installed.

Package Installation

After setting up your new Lubuntu VM you’ll need to update the sources.list and install several components. Lubuntu doesn’t come with various compiling tools, such as gcc and make, and so those must be manually installed:

sudo apt-get update sudo apt-get install build-essential dkms gcc make

Next you’ll need to make sure the kernel headers are installed:

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

Now you’re ready to install the guest additions.

Installing Guest Additions

Click the “Devices” menu on the VM’s menu bar, and select “Install Guest Addtions”.

This will mount a new drive in the VM called “VBOXADDITIONS_(version number)”. Open the file browser and navigate to it. The folder contains a number of scripts, double click the “autorun.sh” script, and select “Execute” when the file manager asks what to do with it. When prompted, give your sudo password.

The script will now install the correct kernel modules and will return “Press enter to close” when completed. Scrutinize the output carefully to make sure no steps failed, then close and restart the machine (I usually just kill it from the VM menu bar). Upon reboot the most obvious sign of success is that you will be able to resize the VM and it will expand or contract accordingly.

Enabling copy/paste and shared folders

To enable text copying and pasting between the host and the VM, click the “Settings” button in the VirtualBox Manager.

You’ll find options to enable copy and paste in the General>Advanced tab. Set “Shared Clipboard” to Bidirectional to enable it between either host or guest.

Creating a shared folder

Shared folders between the host and the VM are absolutely essential for my usage. This gives you the capability of quick and easy transfer of files between the host and the virtual machine.

To enable this, create a folder somewhere in the host filesystem (On my Windows hosts I typically put it in C:, just to make the file paths simpler). In the VirtualBox Settings menu, go to “Shared Folders” at the bottom. Click the add button.

Give the folder name and path, and check “Make Permanent”. Now (in the VM) create a folder in your home directory to represent the shared folder. You can then run

sudo mount -t vboxsf -o uid=1000,gid=1000 host_folder_name /home/username/shared_folder

To mount it. Test it out by copying a file into it from either the host or guest and checking the corresponding folder to see if it shows up. If it does, success!

Next step is to set this folder to automount in the VM at startup. Open a terminal on your Lubuntu VM and type

gksu leafpad /etc/rc.local

This will open the file rc.local in the text editor. Add the following directly before the line with “exit 0”:

mount -t vboxsf -o uid=1000,gid=1000 host_folder_name /home/username/shared_folder

The folder should now automount at startup.

Conclusion

You now have a useful, lightweight virtual environment capable of full interaction with the host machine. If you come across any other tips for better virtualization with VirtualBox, send me an email or comment.