Search This Blog

Showing posts with label SUSE linux. Show all posts
Showing posts with label SUSE linux. Show all posts

Monday, August 11, 2008

Virtualbox shared folder mounting issue: Missing module on opensuse 10.3

The Version combination for this scenario..


This problem was encountered with the following combination:

  • Virtualbox 1.6.4

  • Host OS: windows XP service pack 2

  • Guest OS: OpenSuSE 10.3


A shared virtual folder was defined for the opensuse virtual machine like this:

In the guest OS, a mount point was defined like this:
linux-jo4o:~ # mkdir -p /ddrive

Now when the mount of the shared folder was attempted, this error was received:
inux-jo4o:~ # mount -t vboxsf d_drive /ddrive
/sbin/mount.vboxsf: mounting failed with the error: No such device

An unlikely solution...


It seems that a critical module required for shared mount points was not loaded in memory. Here, we can see that only one module with the vbox pattern in it's name is loaded:
linux-jo4o:~ # lsmod | grep vbox
vboxadd 56232 3

So lets load the vboxsvfs module into memory:
linux-jo4o:~ # modprobe vboxvfs

After that, we can verify that it is really loaded:
linux-jo4o:~ # lsmod | grep vbox
vboxvfs 38184 0
vboxadd 56232 4 vboxvfs

Now, let us mount the shared folder:
linux-jo4o:~ #  mount -t vboxsf d_drive /ddrive

Awesome! That was smooth. Lets check if the shared folder really got mounted or not:
linux-jo4o:~ # mount
/dev/sda2 on / type ext3 (rw,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/sda3 on /home type ext3 (rw,acl,user_xattr)
/dev/sr0 on /media/VBOXADDITIONS_1.6.4_33808 type iso9660 (ro,nosuid,nodev,uid=0)
d_drive on /ddrive type vboxsf (rw)
linux-jo4o:~ #

Yippee!


I can share files with my windows laptop now. Now that was some adventure, eh :)

To make this more permanent, there has to be a way of loading this module automatically. Maybe I can put the modprobe command in /etc/rc.d/boot.local file, but then maybe there is a better way. I leave that to you to figure out.

Package dependency for installing virtualbox guest additions on Open SuSE 10.3

The problem at hand..


Well, I had to get the shared folder feature working on Open SuSE 10.3 virtual machine for a variety of reasons, and in turn, I had to install guest additions on virtualbox 1.6.4. There were a bunch of package dependencies even before coming to this error, and unfortunately, I dont have the entire series of command that I issued, but in this posting, I will attempt to present the solution of the immediate error that I was facing.

The KERN_INCL variable had to be set to the /usr/include directory:
linux-jo4o:/usr/src/linux # env | grep KER
KERN_INCL=/usr/include

After mounting the guest additions CD and running the VboxAdditions.run command as root, the kernel was not able to be compiled and this was visible in the install log:
linux-jo4o:~/addons # more /var/log/vboxadd-install.log

Installing VirtualBox 1.6.4 Guest Additions, built Tue Jul 29 20:13:59 CEST 2008

Testing the setup of the guest system

Building a test kernel module...

make KBUILD_VERBOSE=1 -C /lib/modules/2.6.22.5-31-default/build SUBDIRS=/tmp/sel
fgz1883915647/module/test SRCROOT=/tmp/selfgz1883915647/module/test modules
make[1]: *** No rule to make target `modules'. Stop.
make: *** [vboxadd_test] Error 2

Building the test kernel module failed.
Giving up due to the problems mentioned above.
linux-jo4o:~/addons #

Initial thoughts and a potential solution


Initially, I thought that maybe it was a problem due to missing symbolic link to the modules directory (??), but when I posted this question on the vbox-users mailing list (which I think is more effective than the forums at times), I got a response saying that maybe I should check if the kernel-source package was installed or not.

To even find the package, we needed the main SOURCE repository added in the YAST setup. This is what the installed online repositories looked like:



When I ran the following command as root, it was clear that this was the missing link:
linux-jo4o:~ # zypper install kernel-source
* Reading repository 'Main Repository (NON-OSS)' cache
* Reading repository 'openSUSE-10.3-OSS-KDE 10.3' cache
* Reading repository 'Main Repository (Sources)' cache
* Reading repository 'Main Repository (OSS)' cache
* Reading installed packages [100%]

The following NEW package is going to be installed:
kernel-source

Overall download size: 49.2 M. After the operation, additional 243.4 M will be used.
Continue? [yes/no]: yes
Downloading package kernel-source-2.6.22.5-31.i586, 49.2 M (243.4 M unpacked)
Downloading: media
* Downloading [100%]
Downloading: kernel-source-2.6.22.5-31.i586.rpm
* Downloading [100%]
* Installing: kernel-source-2.6.22.5-31 [100%]
linux-jo4o:~ #

Now, when I tried installing the guest additions, it was able to install them and recompile the kernel JUST fine. Sweet!
linux-jo4o:~ # /media/VBOXADDITIONS_1.6.4_33808/VboxAdditions.run
Verifying archive integrity... All good.
Uncompressing
VirtualBox 1.6.4 Guest Additions for Linux
installation.............................................................................................................................................................................
VirtualBox 1.6.4 Guest Additions installation
Building the VirtualBox Guest Additions kernel module...
Building the shared folder support kernel module...
Installing the VirtualBox Guest Additions...

Successfully installed the VirtualBox Guest Additions.
You must restart your guest system in order to complete the installation.
linux-jo4o:~ #

Friday, April 11, 2008

Migrating from vmware to Virtualbox: Making NAT networking type work with SuSE Linux as guest OS and Windows Host

In the past two weeks, I have discovered a lot about Virtualbox. I wanted an easy alternative to vmware server/player and I had heard at a friend's party that virtualbox was another virtualization software in the market and it was free. Vmware workstation needs a paid license, so I decided to create a working virtual machine in which internet would work.

A difficult virtualbox journey.. from vmware


Intially, I dabbled with all sorts of network setups, but nothing seemed to work.
In the starting, I used static IPs -- 192.168.203.21 for eth0 and 10.10.10.21 for eth1, mostly because I had seen these IPs being used for NAT and Host only network types in Vmware. (later on, I realized that the network functionalities of Vmware and virtualbox are not the same. So host only in vmware may not be the same as host only in virtualbox).

This very setting was working for the SLES9 OS install done in Vmware, with the same setting in virtualbox, the network would not work.

The route command was taking a long time to print the output.

The "route -n" command was coming out with output instantly though, which clearly pointed that the issue was with the name resolution or accessing the names server.

Trivia...


During my efforts to make NAT networking work, on checking the c:\> ipconfig /all output in windows, I could see that the status of Virtualbox TAP adapter (first network interface) was showing as "media disconnected".

I started reading different posts on the internet frantically and came across one very cryptic post at http://eligere.wordpress.com/2008/03/12/virtualbox-windows-tap-disconnected-message-remove/ , which had an interesting hack to make the status of Virtualbox TAP adapter as always connected or with 0.0.0.0 IP when the VM was not started.

The solution was to open up the Device manager in windows, right click on the Virtualbox TAP adapter, go to advanced tab, and select "Always connected" value for the Media Status option.




















After this, the media state always shows as connected with a DHCP IP assigned to it in the subnet 169.254.xx.xx. If you read http://en.wikipedia.org/wiki/Zeroconf, you will come to know that 169.254.0.0 - 169.254.255.255 is a special range reserved for link-local set of addresses.



After making this change, the networking in the SLES9 guest OS STILL DID NOT work!!



Random ramblings...


While searching on the virtualbox forums, I found a lot of posts talking of making Ubuntu work with Virtualbox.


Well, I thought. At least ubuntu seems to work, if not SuSE. So, I decided to virtualbox with Ubuntu guest OS on a windows vista at home.


I discovered that Ubuntu created a DHCP network interface for the first virtualbox TAP adapter, with an IP of 10.0.2.3, and networking was working just fine out of the box!



Trying DHCP for eth0 on SuSE linux..


This lead me on to think that Virtualbox seemed to have a liking for DHCP networking interfaces, rather than static IPs.


Using the "yast2" utility in the previous SLES9 virtual machine, I changed the eth0 network interface setting to DHCP and found that the ifconfig output had assigned an IP of 10.0.2.15 to eth0.


What's more, the route command was not hanging anymore!


Somehow, a default gateway of 10.0.2.2 was being taken up by the OS. (although /etc/resolv.conf had an entry of 192.168.203.2 for the nameserver. Now, that was strange.)


But, internet was not working yet.



Making internet work on SLES9 VM using virtualbox (in office intranet)....


To make networking work on SLES9 virtual machine, I still had do the following things:


1) Copied the DNS servers from the windows host into /etc/resolv.conf . This could have been done through the yast2 utility too.


If I did not do this, then the route command was printing the expected output, but the nslookup for external websites like yahoo.com was failing or hanging.


2) Changed default gateway as 10.0.2.2 through yast2 utility


3) Since I was behind in the office network, I had to setup the corporate proxy too through Yast2. It should be visible in the http_proxy environment variable in the SLES9 guest OS. This was crucial to make networking work. If this was not set, the ARP name resolution was happening, but the connection was hanging.


A really easy way to check the networking connection was to use $ wget yahoo.com, which would tell the entire story very well.


4) Another thing You COULD consider doing (but MAY NOT be necessary) could be syncing up (typing in the same MAC id) the MAC address of the Windows TAP Adapater in the Network setting of the Virtual machine definition in Virtualbox (before the VM starts). This may be relevant if you generated a new MAC id of the virtual network interface or you recreated a new virtualbox network interface.


You may also have to change the new MAC id in name of the file /etc/sysconfig/network/ifcfg-eth-id-<MAC:ID> , which controls the internal names of the network interface.


I started going on this path and did this consistency naming for the first network interface, but did not bother doing so for the other one, and even then networking was working just fine.



Experimenting with 2 NAT type Virtualbox TAP adapters


Then I tried configuring the guest OS VM with 2 NATs and this is how the ifconfig output came up like:



The route command came up like:



I was able to browse external websites ....




An important learning about how NAT works in Virtualbox..


Summing it up, I made an important discovery (for me) about how NAT works in virtualbox.


In reality, the NAT setup was really, really easy and worked for most people. To make it work, all that was needed to be done was let the Guest OS get an IP in the subnet 10.0.2.x through DHCP, have a default gateway of 10.0.2.2 and a names server of 10.0.2.3. With this, everything was hunky dory.


Had I chosen multiple NAT type Virtualbox TAP adapters for the Virtual machine (you can choose upto 4), the third and fourth ones would have acquired IPs in the subnet 10.0.3.x and 10.0.4.x. This is assuming eth2 and eth3 would have been of type DHCP.



Extending this concept to Static IPs..


When I discussed this finding with Srikanth, the sysadmi of my wife's company, he said that since DHCP server is giving an IP in the subnet range 10.0.2.x, one should be able to setup any static IP value for that network interface in the same range!

The more I thought about it, the more it seemed to make sense. And then, try it out I did. And work it did. (Yes, sir). I put eth0 as static ip of 10.0.2.5, default gateway 10.0.2.2, names server 10.0.2.3 and networking worked fine.

So basically, each NAT interface allows you to choose any IP in the range 10.0.N.x, where N >=2 and x ranges from 4 and 255 (leaving off 10.0.N.[1-3] for special functions of default gateway/names server).



Redemption..


Having experimented and dealt in depth with the NAT network interface of virtualbox, I was happy to have learnt something of value in the networking arena, which was an area of improvement for me.

What's more, I learnt that its easier to make networking work in Virtualbox than it is in VMware, provided you let the OS choose the IP in its desired magical subnet -- 10.0.N.x.