Archive for November, 2007

share printer connected to Ubuntu from Windows XP on VirtualBox

Monday, November 5th, 2007
This is as straightforward as setting up a network printer from Windows XP.

First of all you've got to set up a private network connection between the host and the guest operating system.

Then you have to make sure that CUPS is accepting connection from other hosts.

When finished with all this foreplay, you can go ahead and use the printer from Windows XP. Boot your VirtualBox and enter Windows XP. Go to Start → Settings → Printers and Faxes. Click on Add a printer. Tell the wizard that you wish to add a network printer. Specify that you want to Connect to a printer on the Internet or on a home or office network. Specify the URL of your printer. It should be something like:

http://10.0.1.1:631/printers/printer-name

Where in printer-name you should replace the name of your printer. Complete the installation of your printer by specifying the driver to be used. You should now be able to print from your Windows XP now.

ugly looking VirtualBox on Gutsy?

Sunday, November 4th, 2007
So you installed VirtualBox on your new Gutsy Gibbon but got a little shocked when you noticed that your VirtualBox was wearing and ugly Motif-looking theme with ugly large fonts? Me too. And here is how to fix this.

First you have to install the packages qt3-qtconfig and polymer:

sudo apt-get install qt3-qtconfig polymer

Then run Qt Configuration, which you can find in System → Preferences → Qt Configuration. In the Appearance tab go to GUI Style and choose Polymer. Then go to the Fonts tab and a select a nice looking font (my favorite one is Verdana, point size 10). Save your configuration (Ctrl-S) and start VirtualBox. It should be looking nice and cool again.

cannot print from shared printer in Ubuntu?

Sunday, November 4th, 2007
Sharing and using a printer in Ubuntu has turned to a very simplified procedure. However there may be a tiny bit of extra homework you have to do.

By default the CUPS is configured to accept incoming connections only from localhost (yes, I find it kind of odd, too... what's the point of printer sharing if restricted only to local host?).

To fix this you have to edit your /etc/cups/cupsd.conf configuration file:

sudo gedit /etc/cups/cupsd.conf

Go to the section for the listeners configuration (it is not far from the beginning of the file):

# Only listen for connections from the local machine.
Listen localhost:631
Listen /var/run/cups/cups.sock


As you can see it is configured to accept connections only from localhost. Replace localhost with an asterisk to allow incoming connection from outside:

# Only listen for connections from the local machine.
Listen *:631
Listen /var/run/cups/cups.sock


Restart the CUPS system:

sudo /etc/init.d/cupsys restart

Now you should be able to set up network printers from the other computers and use the printer.

TortoiseSVN: missing overlay icons (#2)

Friday, November 2nd, 2007
If you have tried everything but your TortoiseSVN is keenly denying to display the overlay icons on some folders, then maybe this one can help you.

Open the Windows Task Manager (you can do that by pressing Ctrl-Shift-Esc). Switch to the Processes tab and find the process with name TSVNCache.EXE. Kill that process by right-clicking on it and selecting End Process:

screenshot of windows task manager


Then go back to window explorer, to the folder where the overlay icons was refusing to show up. Press F5 (Refresh). Did they show up? At least, it worked for me...

Please note that before you try this tip, you should have configured TortoiseSVN to display overlay icons for the folder type that is causing the problem.

faster access to shared folders on VirtualBox

Thursday, November 1st, 2007
VirtualBox offers the option to access folders of your host from within your guest system, what is called shared folders. Although it is working most of the time, it has caused me several problems like: slow transfer rate, occasional delays and "freezing" and several I/O errors while copying files.

An alternative way to access shared folders between guest and host systems, is to completely by pass the built-in shared folders facility of VirtualBox, and use SMB/CIFS directly over a private network connection between the host and guest system. In my previous post I explain how to set up a private network connection between host and guest. Having done so you can go ahead on this article.

In my example I will describe my own configuration which consists of an Ubuntu host and Windows XP guest. I usually create a folder named xfer in my $HOME directory which I use for file sharing between systems. You can read an older article of mine on how to set up a writeable shared folder with samba on ubuntu.

When your shared folder is all done you can switch to your Windows XP and access it. Go to Start → Run and type \\10.0.1.1\xfer and click Ok:

windows xp run command dialog


Your shared folder should open with no serious delays and browsing should be quite responsive:

browsing network folder


If you'd like to, you could also map a drive letter and assign it to the network path and access the shared folder by only typing the driver letter. I use X: for this purpose:

map network drive

host-only networking for VirtualBox

Thursday, November 1st, 2007
VMware came with a very useful networking feature, called host-only networking, that created a private network connection between the host and guest operating systems. This is feasible with VirtualBox, too, altough not quite as obvious. Here is described how you can do it with Ubuntu host and Windows XP guest system.

First you have to install the uml-utilities package:

sudo apt-get install uml-utilities

Then you will have to create the virtual network interface that the two operating systems will share:

sudo tunctl -t tap0 -u giannis

Of course you will have to replace "giannis" with your own username.

Now, assign the IP 10.0.1.1 to the Host system (Linux):

sudo ifconfig tap0 10.0.1.1

We will now have to make sure that VirtualBox has full access to /dev/net/tun:

sudo chgrp vboxusers /dev/net/tun
sudo chmod 660 /dev/net/tun


You have to add all users of VirtualBox in the vboxusers group. You can to that either by going to System → Administration → User and Groups, or by directly editing your /etc/group file:

sudo gedit /etc/group

Find the vboxusers group:

...
mysql:x:121:
vboxusers:x:1001:
postfix:x:122:
...


And add all the users that will use VirtualBox into it:

...
mysql:x:121:
vboxusers:x:1001:giannis
postfix:x:122:
...


Now start VirtualBox and before you boot your Windows XP, highlight your virtual machine and click on Settings. Go to Network. Find a free network adapter. Enable it and select Attached to: Host Interface. At the Host Interface Settings section go to Interface Name and type in the interface's name, that is, tap0. Click Ok and boot your Windows XP.

When Windows is started, go to Start → Settings → Network Connections. Find the connection you previously added and open its Properties window. Highlight Internet Protocol (TCP/IP) and click Properties. Check the Use the following IP address option. In IP address enter 10.0.1.2. In Subnet mask enter 255.255.255.0. Leave Default gateway empty. It should look like this:

snap of windows xp internet protocol properties



Click OK and then click OK once more. That's it. Now you should be able to access each from the other. To test if your private networking really works, try to ping each host from the other.

From Host (Ubuntu) use the IP 10.0.1.2 to ping the Guest (Windows XP):

giannis@giannis-laptop:~$ ping 10.0.1.2
PING 10.0.1.2 (10.0.1.2) 56(84) bytes of data.
64 bytes from 10.0.1.2: icmp_seq=1 ttl=128 time=0.455 ms
64 bytes from 10.0.1.2: icmp_seq=2 ttl=128 time=0.951 ms
64 bytes from 10.0.1.2: icmp_seq=3 ttl=128 time=0.368 ms

--- 10.0.1.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.368/0.591/0.951/0.257 ms


Note that you will have to disable firewall for that network interface in Windows XP in order for ping to work.

From Guest (Windows XP) use the IP 10.0.1.1 to ping the Host (Ubuntu):

C:Documents and SettingsGiannis>ping 10.0.1.1

Pinging 10.0.1.1 with 32 bytes of data:

Reply from 10.0.1.1: bytes=32 time=14ms TTL=64
Reply from 10.0.1.1: bytes=32 time=1ms TTL=64
Reply from 10.0.1.1: bytes=32 time<1ms TTL=64

Ping statistics for 10.0.1.1:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 14ms, Average = 5ms
Control-C
^C


Although all settings applied to the network interface in Windows will be available every time you boot Windows, the virtual network interface will go away next time you shut down your Linux system. One easy solution to this, is to add the commands that set up your network interface in your /etc/rc.local script:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

echo "Setting up tap0 interface..."
tunctl -t tap0 -u giannis
ifconfig tap0 10.0.1.1


exit 0


Now the tap0 interface will be available every time you boot your Ubuntu system. Note that you do not have to use sudo inside /etc/rc.local as this script is executed by root anyway.



Update on: December 13th, 2008

Here is also a tip from Ale Feltes Quenhan: you can also have NAT working by running the following two commands:

# iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
# echo "1" > /proc/sys/net/ipv4/ip_forward


making sure to replace eth1 with the interface that gives your host machine an Internet connection.

Thanks to Ale.