Thursday, August 5, 2010

tun module fails in Ubuntu 10, install fake tun

Problem: In Ubuntu 10.04, tun fails. while running the command
$ sudo modprobe tun
results into
tun module failed

The tun module is used in several VPN softwares like hamachi

Resolution:

Install fake tun in Ubuntu. Then run the command 'sudo modprobe tun'
Note: You need to be one of the admins (in sudo group).

To install fake tun, copy/paste and then run each command (below) separately. Make sure there is no line-breaks within a command

$ sudo apt-get install build-essential linux-headers-`uname -r`
$ mkdir faketun
$ cd faketun
$ echo -e "#include \nstatic int start__module(void) {return 0;}\nstatic void end__module(void){return;}\nmodule_init(start__module);\nmodule_exit(end__module);">tun.c
$ echo -e "obj-m += tun.o\nall:\n\tmake -C /lib/modules/\$(shell uname -r)/build/ M=\$(PWD) modules\nclean:\n\tmake -C /lib/modules/\$(shell uname -r)/build/ M=\$(PWD) clean\nclean-files := Module.symvers">Makefile
$ make
$ sudo install tun.ko /lib/modules/`uname -r`/kernel/net/tun.ko
$ sudo depmod -a
$ sudo modprobe tun
Incase, you get an  error, check tun.c and Makefile files (in the faketun folder) are created correctly. You may download the files from the address below, into the faketun folder, and then start from the 'make' command again:

File: tun.c download link


File: Makefile download link

Installing Guest Additions in VirtualBox

VirtualBox has made it pretty easy to install the Guest Additions for improved integration between guest and host. Some of these benefits are mouse-capture improvements and improved video resolution. The mouse capture improvements now allow you to control your virtual machine when the mouse is over the window, and seamlessly return to your host when it is not. Improved video resolution should allow you to customize a better resolution for your guests.

What we need to do to install the Guest Additions is select the option from the VirtualBox menu. You’ll want to do this after your guest is running (the guest-additions are installed to the guest, not the host). Select:
Devices > Install Guest Additions...

This sometimes takes a minute so don’t worry if you don’t see anything right away. This should then prompt you and say something along the lines of:
The Guest Additions image is not found on your host. Would you like to download this image now?

We’ll select YES and let it download the image. The image is downloaded to the host machine and then mounted within the guest. This way it can be shared with future guests without needing to download multiple times. It should also prompt you whether or not you’d like to mount the image. Again, select YES.

At this point you should see a disk image mounted on your desktop. What we’ll do here is run a script that will generate the proper modules to allow for guest additions. In my preferred method we’ll do this:
  1. Open a terminal by pressing ALT-F2 and enter “gnome-terminal” on gnome or “konsole” on KDE.
  2. cd /media/cdrom
    The Guest Addition iso file do not mount automatically sometimes. In the case if you do not see a cdrom, run sudo mount /dev/scd0 /media/cdrom
  3. sudo bash ./VBoxLinux*
    OR
    sudo sh ./VBoxLinuxAdditions-x86.run
    OR
    sudo sh ./VBoxLinuxAdditions-amd64.run

This will grind away at generating the proper modules and then prompt you to restart your guest machine. Once this has finished and you’ve rebooted your guest operating system you should have the guest improvements ready to go. No additional configuration for the mouse integration should be needed, but you may have to manually update to a better resolution as wanted.

Hopefully I’ll have the tutorial for building proper network bridging soon as well. Until then, enjoy your virtualization with VirtualBox!

_____________________________________

This article is taken from http://ubuntu-tutorials.com

Keyboard stops working in Virtualbox guest

Problem: Sometimes the keyboard would stop working in Virtualbox guest. The mouse works. The issues temporarily disappears on rebooting the guest.

Suggested solution: If you are in Ubuntu host, install the packages scim-bridge-client
sudo apt-get install scim-bridge-client-qt scim-bridge-client-gtk

Reboot the host.

The issue should be fixed by now.