TurnKey Linux Virtual Appliance Library

Adding host folders to file server

I have the mediawiki and fileserver appliances running on a server at work.  The mediawiki is running perfectly, but I am having issues with the fileserver.  Both are being run by virtualbox, but what I cannot seem to achieve is "mounting" external folders such that they can be accessed by the fileserver VM.

I've done the normal thing for virtualbox; addedd the path to the folders I want the VM to "see" to the VM setup.  However, when I start the file server, these folders do not appear to be mounted anywhere.  I've searched the forums to no avail.  It is quite critical this works, as the main storage for the server is an expandable, rack-mounted system that the host machine actually controls.  Ergo, not being able to access the "folder" on the guest where these drives are mounted means that the file server doesn't have access to the place where files are to be stored.

I suspect I need to add the virtualbox guest additions, although my first attempt at doing that permenetly screwed up the file server (no boot after install; thank goodness it was a VM).

Any advice is appreciated.

Bryan

Jeremy's picture

Need to mount location

In your fileserver you'll need to set up the location to mount (this doesn't happen automatically unless you explicitly configure it). And yes if you wish to use the VBox 'shared folders' feature then you'll need to install VBox guest addons.

There are other ways you could go about this too, such as using a Samba share (assuming that your host server is Windows - use NFS if its a Linux server).

Although to be completely honest, it seems to me like a convaluted way of doing it... Why not just share the folder on the host OS? Or better still install TKL fileserver appliance directly on the "expandable, rack-mounted system"?

Need to mount location

Or better still install TKL fileserver appliance directly on the "expandable, rack-mounted system"?

Because the computer serves other purposes, and is running another linux distro to meet those ends.  TLK file/wiki servers don't consume much; essentially two small applications running in the background.

 

Although to be completely honest, it seems to me like a convaluted way of doing it... Why not just share the folder on the host OS?

 

I was using TKL to get "easy" support for multiple users.  I may try the above, but because of the other things the server does (its linux based, fwiw) I'm not sure how well that will implement.

Thanx for the avice

Bryan


Success!  For anyone who ever

Success!  For anyone who ever needs to do this in the future, you need to do the following:

1) login as root
2) apt-get update
3) apt-get install dkms
4) sudo apt-get install build-essential
5) apt-get install linux-headers-$(uname-r)
6) reboot
7) mount the virtualbox guest addition iso
8) install the linux guest additions, using the --nox11 tag to reduce error messages
9) Reboot; shared folders should appear under /media/

Bryan

 


Jeremy's picture

Thanks for posting back

Glad you got it working how you want! :)

L. Arnold's picture

Excellent.. lets all try that.!

I have used the File Server and Domain Controller both to share folders from Windows Boxes but I have not tried it from Linux...   It seems you actually did this via VBox addons.  I'll bet you can also use some CIFS type sharing etc, which would need to be researched.

By Default TKL boxes are set up as Servers more than Clients and technically using that shared folder is a client type activity.  Shared folders within VBox or VMWare are, I think at present, outside of the realm of most TKL configurations but they can be very helpful.  As an example I recomend using Snapshot's from time to time if they are available to you.

Two steps back...

My victory dance was early.  I've got the host folders mounted (they auto-mount in the /media directory).  If I log into the TKL guest I can read/write to those folders all that I want.  However, I seem to be completely unable to share those folders as a samba share.

I'm sure I'm setting up user accounts, etc, properly, as I can make a folder anywhere else in the TKL system and share it successfully.  Its only the shared folders that do not work.

Any idea what may be going wrong?


Bryan


Jeremy's picture

Not sure

I don't know enough about VBox shared folders to be of any reeal help to you, but perhaps there is some conflict between VBox shared folders and Samba? Perhaps check Samba error logs and see if there is anything of interest there. I'm not sure exactly what it'd be called but I would imagine you will find it in /var/log (that's where all log files should be).

Another attack you could try is to set up a Samba share somewhere else (that works - like you said you've been able to) and put a symlink to the VBox share in that. Not sure if it'd work but could be an easy hack if it does.

The other options are to install Samba on the host system and share direct from that (or you could try sharing that through your fileserver appliance). Or as your other host system is Linux too, you could try using NFS (Linux native network filesharing) and mount the NFS share in your fileserver and re-share that using Samba. Although TBH, re-sharing folders from your fileserver appliance may not work either if the current problem is a limitation of Samba (ie you may hit the same wall?)

Finally!

A bunch of banging my head on the wall later and I've made it work.

The virtualbox additions creates a user and group on the TLK guest for virtualbox-specific tasks (UID = vboxadd, group = vboxsf).  The issue was simple; any traffic in/out of virtualbox shared folders must be by someone belonging to the right group, or by the vboxadd user itself.

So the solution was easy; set it up as I described above.  Mount the vbox shares, and when creating the SAMBA users make sure that they are assigned to the vboxsf group (along with any other groups you need for management.

Now, one last (probably dumb) question - I'm managing access to the shares using groups.  But any share I create seems to allow all users to read the share, while the assigned group has read/write access.  Is there anyway to outright exclude all users but those found part of the read/write group?

Bryan

EDIT: forgot to add, when creatin the shares you must configure them to force the user and group for all new files/folders to vboxadd/vboxsf.


Jeremy's picture

Nice work

Great you got that working and thanks for posting back.

As for your sharing requirements, I'm not sure if it's the best way, but the way I set up my shares is use Samba permissions to allow read access to shares (but set them to read/write for all that you want read access) and then use Linux file permissions to control write access. Assuming that the Samba and Linux user databases are correctly synced this works really well for me - only users/groups with Samba permissions can see the shares and only users with Linux permissions can write to them.

Just to follow up

I realize this is an old thred, but for anyone who stumbles upon it.

Any time the kernel gets upgraded, you must repeate the process described in my post dated Wed, 2012/01/11 - 17:55.  For reasions I don't understand, kernel upgrades do not upgrade the headers...

Bryan

Can't compile the guest additions

Hi

Appliance: Turnkey fileserver (VMDK download).

I went through Bryan's instructions but the guest additions failed to compile. Last few lines of installer log file displays as follows:

include/linux/skbuff.h: In function '__skb_cow':
include/linux/skbuff.h:1537: error: implicit declaration of function 'ALIGN'
In file included from include/net/dst.h:16,
                 from include/net/sock.h:60,
                 from include/linux/tcp.h:177,
                 from include/linux/ipv6.h:215,
                 from include/net/ipv6.h:16,
                 from include/linux/sunrpc/clnt.h:25,
                 from include/linux/nfs_fs.h:51,
                 from /tmp/vbox.0/utils.c:25:
include/net/neighbour.h: At top level:
include/net/neighbour.h:115: error: variably modified 'ha' at file scope
/tmp/vbox.0/utils.c: In function 'sf_path_from_dentry':
/tmp/vbox.0/utils.c:362: error: implicit declaration of function 'utf8_wctomb'
/tmp/vbox.0/utils.c: In function 'sf_nlscpy':
/tmp/vbox.0/utils.c:420: error: implicit declaration of function 'utf8_mbtowc'
make[2]: *** [/tmp/vbox.0/utils.o] Error 1
make[1]: *** [_module_/tmp/vbox.0] Error 2
make: *** [vboxvfs] Error 2

Any help on resolving above would be appreciated. I am running Virtual Box on an Ubuntu Oneiric host. I'd hoped the fileserver VMDK file would automatically include the guest additions but apparently it doesn't although in the Turnkey guest there's a file /sbin/mount.vmhgfs which I tried using:

mount -t vmhgfs .host:/home/maths /mnt

... resulting in the following error message

Error: cannot mount file system: Protocol error.

I do not know what's the difference between vmhgfs and vboxsf filetypes ??

Neil.

Solved compiling problem

Hi again

Ok. I solved my own problem. I had downloaded the wrong version of the guest-additions iso. I found the correct version (or at least one that worked) here:

Guest Additions Iso for Ubuntu Lucid

Neil.

Guest additions

Just a thought - why don't you guys (ie Turnkey) simply build your vmdk for the fileserver with guest additions included?

I created my own VM by loading the normal filserver iso and then installing the guest additions. I also installed a dhcp server and everything works perfectly - just the same as my ordinary Turnkey fileserver. So the VM provides a useful backup system if I need it.

Compliments again - Turnkey fs is a really useful and reliable product in whatever form you choose to use it!

Neil.

Jeremy's picture

AFAIK it already does

AFAIK the vmdk build already includes the basic VMware 'guest tools'. I don't think that it includes the VBox 'guest tools' though.

I remember reading somewhere that at least part of the rationale was that the VBox tools were much easier to install, and that they were also less useful (don't recall exactly, but think that it had something to do with the way the virtualisation was implemented, VMware guests are less functional without the 'tools'?) It may also have something to do with licencing? I know that the VBox tools aren't open source (although TBH I'd be surprised if the VMware tools were).

Either way, personally I don't see the point in using them (the 'guest tools') with a server OS (no GUI - so no need for the graphics bit), especially when the Fileserver appliance is already set up with Samba/Win filesharing which can be accessed/mounted/mapped from any host OS. And if you use Linux or OSX then you can use SFTP from the file manager instead if you desire.

Use of guest additions.

In respect of the guest tools, the main option I need enabled is not GUI related stuff but access to Vbox shares on the hosting system. In my case that system chops and changes very often because I am experimenting all the time with different flavours  and versions of Linux which usually means re-install from scratch and it's a pain reconfiguring samba every time I do that - much quicker to recreate VM using existing vdi file. So running Turnkey either as a standalone fileserver or as a VM solves the config problem. (For the VM the stuff that's actually shared - via Vbox shares - is all on /home which is configured as a separate partition and so can live on from one Linux to the next.)

Windows server costs $$ but I think Vbox is free. Using a VM, you can easily supply file services from a Turnkey system. But once again you need the guest additions for access to Vbox shares on the hosting Windows. Sure - you could also download samba (or other fs system) for Windows but that's another mission! In my (franchise) business, most of us (not me!) live in the Windows world and so would appreciate a 'turnkey' fileserver solution that effectively runs under Windows. Turnkey VM has a minimal footprint (my vdi file is 2Gig & uses 512M memory) and does all of that - Vbox makes it pretty easy to set up the supplementary Vbox shares from the Windows host. Also once I have the VM configured correctly for use here, it will work elsewhere (in the franchise) the same way since we are all using the same server installed software.

Jeremy's picture

No need to install Samba on Windows

Having VBox tools pre-installed may be your preference (and perhaps ideal for your scenario), but using a shared folder from your Windows host may be easier than installing VBox tools? Samba uses SMB/CIFS which is Windows native filesharing. Obviously TKL Fileserver works as a fileserver (it's intended use) but it can also work as a client (ie connect to Windows shares) - so no additional software required to install on either TKL Fileserver or the Win host.

While this won't work OOTB for some TKL appliances (as most of them don't have Samba preinstalled) it works fine for the Fileserver appliance. Even for the other appliances, if you only want to connect to a remote Win share (rather than create SMB/CIFS shares in Linux) this is easily configured. I have just created a wiki page on how to do this (I was going to post here but figured a wiki page may be better).

So you could easily create a script to configure this automatically for any new TKL appliances you install. Here is an example script (adjust the variables to suit your setup) that you could copy/paste in. Another alternative is to save the script on your host and copy it across (eg with SFTP via Filezilla or similar).

Create the file:

nano automountcifs.sh

the script:

#!/bin/bash -ex
# script to configure TKL appliance to connect to a remote Windows share

# set variables - adjust the value on the right to suit your system
winserver=WinPC
winshare=share
winuser=Win-user
pass=pass
workgroup=WORKGROUP
localfolder=/media/win-share

# install smbfs - uncomment if using on TKL appliance other than Fileserver
#apt-get update && apt-get install smbfs -y

mkdir $localfolder
echo "//$winserver/$winshare $localfolder cifs username=$winuser,password=$pass,workgroup=$workgroup 0 0" >> /etc/fstab

make it executable:

chmod +x automountcifs.sh

and run it:

./automountcifs.sh

As fstab is readable by anyone your password will be readable by all. There are a number of ways to get around that if you desire, but i wanted to keep it simple.

FWIW VMware server is free (but not open source) last time I used it, although I never used the host shared folders but AFAIK it should work OOTB (as I said VMware tools should be installed and ready to go on TKL VM appliances).

Fstab entry.

Am doing the exact same thing on my Turnkey VM. It just doesn't need separate hardware to operate on! Following is the entry in /etc/fstab.

M2      /home/maths/M2  vboxsf  uid=1000,gid=100

No additional shares required other than 'homes' on the samba server. Workstations access the share under user maths and find the M2 directory in place as required. M2 share is declared when setting up the VM under Vbox.

Neil.

Jeremy's picture

I don't quite understand..?

What do you mean doesn't need separate hardware? You can connect to a Win share from a TKL Fileserver VM OOTB, just need to mount it (plus make the mount point if it doesn't already exist). As long as there is a LAN/ethernet (virtual or otherwise) connection to the machine with the Windows folder you want access to it will work fine.

Seeing as you still need to edit fstab to make the shares auto-mount and new shares need to be added to fstab too, where is the advantage in using VBox shared folders over CIFS? Perhaps I'm missing something but just seems like an extra step (ie installing/configuring VBox tools) to acheive the same ends to me. I guess that's why you requested inclusion of VBox tools? But still if the same ends can be acheived OOTB as is... Is there some other benefit in using VBox shares/tools that I'm overlooking?

FWIW if you mount a Windows share with cifs and want to have full read/write as a user other than root then you also need to supply a UID and/or GID like is in your VBox fstab line (probably the same ones you used would work fine).

VM debate

If it's relevant to other users, I'm happy to continue the debate on forum space but if you'd prefer can also do by email - floridamaths <at> gmail <dot> com ?

Jeremy's picture

Good call.

I think it's a worthy debate to have here on the forum but you are right in the sense that we probably shouldn't hijack this thread any further. So I have started a fresh thread over here. I put a link back here but also (very) briefly summarised the debate so far. Please feel free to elaborate if you'd like but I think I got it in a nutshell pretty much.

I also am about to obfiscate your email a littlte too so you don't get spammed too much. Hope you don't mind - if you'd rather it be an obvious email link please accept my apology and change it back and I will leave it be.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)