April 15, 2007

How to install Virtualbox in Ubuntu Feisty

04 October 2008
This post is considerably outdated. Virtualbox 2.0 and Ubuntu Intrepid (8.10) have been released. So while some of the steps might still be valid, it would be wiser to refer to the current documentation.


Virtualbox is a new opensource virtualization solution made by Innotek. It has all the features that vmware offers and is a smaller download and easier to install. It therefore appears poised to replace vmware as the main virtualization software in Ubuntu. This is a brief howto for installing Virtualbox on Ubuntu Feisty. It is based on two installations I did recently. By providing the relevant instructions on one page, I hope to make it easier for others to follow. Any feedback about problems or suggestions to improve the tutorial are welcome. Here we go.

First install the dependencies that are not present in Feisty by default.

sudo aptitude install libqt3-mt libxalan110 libxerces27

Now download the debian package for edgy and install it.

*UPDATE: A debian package is now available for Feisty. Replace 'edgy' with 'feisty' in the next two lines to use it.

cd /tmp
wget http://www.virtualbox.org/download/1.3.8/VirtualBox_1.3.8_Ubuntu_edgy_i386.deb
sudo dpkg -i VirtualBox_1.3.8_Ubuntu_edgy_i386.deb

You will have to accept the PUEL license and select "yes" when asked if the vboxdrv kernel module should be compiled. The kernel should be created successfully now. A group called vboxusers is created and you have to add yourself as a user of this group.

sudo adduser $USER vboxusers

If you want to access usb devices from the virtual machine, follow these steps. You can omit them and directly reboot if you are not going to be using usb devices from the guest.

sudo addgroup usbfs
sudo adduser $USER usbfs

** For the next step you have to know the id for the usbfs group that you have created. To do this try

cat /etc/group | grep usbfs

and look for the number after "usbfs:x:". In the next command, replace 1002 in the next command with this number**
echo "none /proc/bus/usb usbfs devgid=1002,devmode=664 0 0" | sudo tee -a /etc/fstab

Now reboot to allow the new group and user permissions to be updated.

start VirtualBox

VirtualBox &

Once you create a virtual machine and install an OS on it, you may want to set up a shared folder between the host and the guest. Suppose the name of the virtual machine is "winXP" and the folder you wish to share is at /home/user/shared. Power off the virtual machine and then do this :

VBoxManage sharedfolder add winXP -name "sharedfolder" -hostpath "/home/user/shared"

Now you can mount the shared folder within the guest. For a windows guest you would boot up and then in the terminal type

net use G: \\vboxsvr\sharedfolder

Now you should be able to access the shared folder from within the guest and the host systems. To access a USB device from the guest, select the device in the USB controller in VirtualBox and enable it. Remember that the device may not be accessible to the guest if it is mounted in the host.


Edit (21 April 2007) - Corrected command for appending line to fstab. Thanks to ebash from Ubuntu forums for pointing out the right way to do it.


Powered by ScribeFire.

April 9, 2007

Hide and show panels with a keyboard shortcut in Ubuntu


I usually keep the default top and bottom panels in gnome, but especially on my laptop, place great value on the screen estate that I can get by hiding them. The usual way I do this is by using autohide and then setting the hidden size to 0 or 1. Mostly I dont need the panels because I can launch applications with Alt-F2 or with shortcuts. But when I need to access something from the panel, I have to mouse over the hidden panel to bring it up. The other minor irritation is that the panel may spring out when you dont really want it if your mouse wanders close to it.

In a recent post in the Ubuntu forums, it was suggested that it would be nice to set up a keyboard shortcut to show the panels when needed. Since it is easy to access the gconf-editor from the command line, it was easy to write a script to toggle the hide status of the panel. Here is a short how-to if someone is interested.

Copy this script, paste it a file and save it as toggle.sh. A good way to place it will be /home/username/.toggle.sh.

#!/bin/bash

#find the current state of the panels
state=`gconftool-2 --get "/apps/panel/toplevels/top_panel_screen0/auto_hide"`

#if autohide on, turn it off
if [ $state = "true" ]; then
gconftool-2 --set "/apps/panel/toplevels/top_panel_screen0/unhide_delay" --type integer "0"
gconftool-2 --set "/apps/panel/toplevels/top_panel_screen0/auto_hide" --type bool "false"
gconftool-2 --set "/apps/panel/toplevels/bottom_panel_screen0/unhide_delay" --type integer "0"
gconftool-2 --set "/apps/panel/toplevels/bottom_panel_screen0/auto_hide" --type bool "false"
fi

#if autohide off, turn it on
if [ $state = "false" ]; then
gconftool-2 --set "/apps/panel/toplevels/top_panel_screen0/unhide_delay" --type integer "100000"
gconftool-2 --set "/apps/panel/toplevels/top_panel_screen0/auto_hide" --type bool "true"
gconftool-2 --set "/apps/panel/toplevels/bottom_panel_screen0/unhide_delay" --type integer "100000"
gconftool-2 --set "/apps/panel/toplevels/bottom_panel_screen0/auto_hide" --type bool "true"
fi


Make the script executable:

chmod +x ~/.toggle.sh


Open gconf-editor and under /apps/metacity/keybinding_commands, change the value of command_1 (or any other unused command) to /home/username/.toggle.sh.

Then under /apps/metacity/global_keybindings, change the value of run_command_1 (if you used command_1 for the script) to controlF12 or any other key combination that you want. There, you are done! Now pressing the key combination will toggle the panels to hide or show. I have tested this with metacity and beryl on gnome and it works perfectly.

Edit: 10 April 2007 - Thanks to dzv (in the Ubuntu forums) for comments and the suggestion to change the unhide delay so that the panel stays hidden.





Powered by ScribeFire.

April 6, 2007

An interactive Linux command line tutorial

Edit: A new version of cmd-tutor is now available. See here.


There has been a gradually increasing influx into the linux community in recent years. The release of Vista has encouraged a lot of people to take the plunge and switch to linux. And while it is not any more essential to use the command line to manage your linux desktop today, many newcomers are interested in knowing what it is all about.

A lot of excellent tutorials are available, like this for example, but there were some requests for an interactive tutorial. Those who have tried the online ruby tutorial will know what I am talking about.

So, I wrote this tutorial in python. Keeping in line with Unix philosophy, the mechanism for presenting the lessons is kept separate from the lessons itself. Therefore it is easy to extend it by adding more lessons later. Currently there are 5 lessons that I have written. These would serve as a gentle introduction to a newcomer.

You have to be running linux to use this. You can download cmd_tutor here. The instructions to install are in the package. Briefly, you have to extract the package somewhere, navigate to the src directory from the terminal and then type 'python install.py install' with superuser privileges. Once installed, you can type 'cmd_tutor' in the terminal to start the tutor.

Any comments and suggestions will be welcome.