Wednesday, April 4, 2007

fusesmb howto

fusesmb is a userspace application that allows you to mount your whole CIFS/SMB based network neighborhood to your filesystem.

This little app solves a whole bunch of headaches that I've had for a long time with KDE applications. Almost none of them support streaming from network locations, so while you can get to the files with smb://server/share/superkewlsong.mp3 you can't play it in your application from there. KDE will download the whole thing to a cache, which it then leaves on your hard drive, and play it locally.

This really sucks for divx video files of about a gig each, so to take the burden off of KDE, since it can't seem to pipe file data via it's network stuff, I use fusesmb.

To install it in FC6 you
localhost ~]$ sudo yum -y install fuse-smb
This installs the software, then you have to edit the file ~/.smb/fusesmb.conf to add your username/password and tell it to show hidden shares or ignore specific servers.

localhost ~]$ nano ~/.smb/fusesmb.conf

The website documentation for fusesmb is really skimpy, but you can get a sample config from man fusesmb.conf which is pretty easy to manage

; Global settings

; Default username and password

; List hidden shares

; Connection timeout in seconds
timeout = 10

;Interval for updating new shares in minutes
interval = 10

; Section for servers and/or workgroups to ignore

; Share-specific settings

; Server-specific settings

Once you've configured that, you got a good shot that your shares will all show up. My setup, of course, didn't work out of the box.

The file ~/.fusesmb.cache would never pickup my XP machine with my music collection on it. It would find all the other shares on my network fine, and if I used the credentials in the fusesmb.conf file to smbbrowse to it I had no problems.

I manually added it to the flat file that has the shares in it of ~/.fusesmb.cache and it would work for a few minutes then disappear!

After some trial and error I found out that fusesmb.cache is not just a file with a plain text list of shares on your network neighborhood, it's also an application that runs and rescans that file every 10 minutes.

So I ran the fusesmb.cache with a -h to see if it took some arguments or something and it actually started spewing some information.

Server: : Share: IPC$ : Workgroup: WAG3SLAV3
Kinit failed: Cannot resolve network address for KDC in requested realm

Fusesmb tries to auth against kerberos and will fail if your linux machine isn't a member machine of the domain. Fortunately with the - tag the fusesmb.cache application will find all your hosts. Must be a timeout thing.

localhost ~]$ fusesmb.cache --

To workaround this rename /usr/bin/fusesmb.cache to /usr/bin/fusesmb.cache.back after it populates the text file ~/.fusesmb.cache

localhost ~]$ fusesmb.cache -- && sudo mv /usr/bin/fusesmb.cache /usr/sbin/fusesmb.cache.back
Just be sure to run fusesmb.cache.back -- if you make a new share on your network because it won't be picked up until you do.
localhost ~]$ /usr/bin/fusesmb.cache.back --


Sebastian said...

Or just set 'interval' to 0 in fusesmb.conf, then it wont recreate the fusesmb.cache

Kostya said...

Thanks a lot for all these details. (With this stupidity of mine I shouldn't be using linux, but ... have been using it for 6 years now.) I haven't found so far ANY information about just HOW i should mount my samba shares using fusesmb utility. Yes, I can see now how fusesmb.conf works and so on, but absolutely NO information on this primary question: how do we mount our shares? Or: where do I find my shares after I did all this preconfiguration? Yea, in Konqueror, I know, you type smb://... Now what do I do to use fusesmb? Any kind of fstab-like file or something? Will be very thankful for any hints.

Kevin said...

For the benefit of someone happening across this thread by a web search... from the fusesmb man page:

fusesmb mountpoint [options]

Many examples on the internet have you create a "~/Network" folder, then run fusesmb over that. The folder can be anywhere on your system, pretty much as long as it's empty and you have write access to it.

A command like "fusesmb $HOME/Network" can then be put in your .Xclients (or KDE "autostart" file, or ~/GNUstep/Library/WindowMaker/autostart, etc., etc.) or .profile (for console logins) to mount the SMB filesystem when you first log in. Running the same mount command over an existing fusesmb mount will emit a harmless error, so it doesn't hurt anything if the command gets run more than once in your login session.

The man page (at least for Debian) may not show all the supported options, but fusesmb -h | less will. One sometimes handy option is "-o allow_other" which would be what you wanted if you mount your "fusesmb" filesystem (as root) at system startup. Otherwise, you'd be unable to get into the fusesmb directory, instead seeing a weird listing like this (the "tmp" folder in this example):

kernst@blackjack:/mnt$ ls -l
total 8
drwxr-xr-x 2 root root 4096 2006-11-19 19:07 artoo/
drwxr-xr-x 2 root root 4096 2008-01-19 23:18 loopback/
drwxr-xr-x 3 root kernst 4096 2008-01-24 22:01 net/
?--------- ? ? ? ? ? tmp

As a side note, as of yet I haven't been able to get a "fusesmb" mount to work within /etc/fstab, although the FUSE documentation clearly states that it's possible (see the FUSEWiki FAQ).

Kostya said...

Yea, thanks a lot, figured that already. Really very simple and unsophisticated. Still, a good explanation necessarily includes an example; so the man page should have some obvious config examples on this also. My own situation shows just why this is necessary: I needed to quickly adopt this new cool fusesmb feature, needed it right away to continue some urgent work (I work in Linux only). And, obvious as it seems, it took me hours to make it work. It's all about speed; generally, in my 6 years of using Linux there was not a single problem/task/configuration that I couldn't solve after all. But sometimes you need it quickly.

F said...

I have a script which used to use the smbmount command to mount a samba share to a specific mountpoint inside my home directory. Unfortunately, the script doesn't work anymore with the new version of Samba in Debian testing (Squeeze).
I decided to give a try at fuse which I already use for sshfs, but I wasn't able to find any information about how to 'convert' the smbmount [share] [mountpoint] command to a fusesmb command.
Any help appreciated.