Tuesday, December 8, 2009

OEL, VirtualBox and Shared Folders

Inspired by Jake's difficulty with getting Virtual Box's Shared Folders to work with Oracle Enterprise Linux (OEL), I'm writing it up...I'm sure he's not the only one with problems.

Most awesomely, he had members of the Sun VirtualBox team commenting on his post.

It's funny, I just got this working a couple of weeks ago. I would typically go his route, get the guest machine working and then download the software from there. Since I have limited space, I tend to create smaller VMs, usually around 10GB or 15GB for database servers. These are sandboxes, a way for me to learn certain aspects of the database (as well as installation).

So here we go. I'm assuming you have your VM running. First, go to Devices:



Next, choose Shared Folders



You should then see this window



Click on the little icon in the top right corner



You'll then be asked to choose a directory (on your host machine)



I chose /opt/software



Name it something you'll remember, like "software" and check the "Make Permanent" check box:



Back to the Shared Folder screen and it should look like this



Go ahead and select "Ok"

Now, open up a terminal and login as root:
[oracle@localhost ~]$ su root
Password:
[root@localhost oracle]# /sbin/lsmod | grep vbox*
vboxvfs 47776 0
vboxadd 70144 5 vboxvfs
I'm just checking to see if the VirtualBox shared folder module was loaded into memory. Sometimes it's not and I found the solution here. Never in a million years would I have thought to check to see if the module was loaded into memory. In fact, I have no idea what a module is.

If you do the lsmod | grep vbox* trick and find that vboxvfs is not loaded into memory, follow the steps included on the link. OK, I won't make you do that.
[root@localhost oracle]# /sbin/modprobe vboxvfs
That should load it. If you get a "file not found" type of error (I can't remember the exact error), you'll probably need to reload the guest additions. If you used the "x11" switch, don't use it this time.

Finally, you can do this
[root@localhost oracle]# ls /mnt
software
[root@localhost oracle]# mount -t vboxsf software /mnt/software
[root@localhost oracle]# cd /mnt/software
[root@localhost software]# ls -l
total 12
drwxr-xr-x 1 root root 4096 Dec 7 17:21 method_r
drwxr-xr-x 1 root root 4096 Dec 7 17:19 oracle
drwxr-xr-x 1 root root 4096 Nov 24 12:34 other
And voila! You now have shared folders.

One last point, if you try to add this to your mount file, it won't work, watching OEL boot-up, it seems the VirtualBox components are loaded after any drives are mounted. I'm sure there is a way to change this...but it's outside my realm.

1 comment:

Bradd Piontek said...

What exactly were the issues Jake was having? I don't recall having any problems with this on OEL or Ubuntu.

One issue I did just run into was with VirtualBox 3.1.0 and OEL5 x86-64. I presume this is a bug in the Linux x86-64 Guest Additions for 3.1.0. The issue is odd as when you mount the filesystem, you get a strange error back. Checking the syslog gets you a little bit more info.

The long of the short of it is that the symbolic link /sbin/mount.vboxvs points to the 32-bit version, not the 64-bit version.