Feature #323

Need automounter for smb

Added by Hammel about 5 years ago. Updated almost 5 years ago.

Status:ClosedStart date:05 May 2014
Priority:HighDue date:
Assignee:Hammel% Done:


Category:04 - Root File System
Target version:0.9.0
Severity:03 - Medium


A PiBox Media Server or Media Player should automatically locate and mount local PiBox servers. This can be done with a simple daemon that queries the network periodically looking for the right workgroup (I think).

I could try using autofs though its probably faster to just write a simple app to do it.

Associated revisions

Revision a9213ee3
Added by Hammel almost 5 years ago

RM #323: Added support for automounting smb shares.

Revision b6fdebba
Added by Hammel almost 5 years ago

RM #323: Add support for testing if running as root.

Revision b1ba5870
Added by Hammel almost 5 years ago

RM #323: Add smb automounting support through timer function.


#1 Updated by Hammel about 5 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

Command line tools for probing can be found on ArchLinux wiki.

#2 Updated by Hammel about 5 years ago

  • % Done changed from 10 to 20
Finding smb shares can be done a number of ways. In order of what I think is easiest:
  1. findsmb, which is available in buildroot but requires adding perl to the build.
  2. smbclient -N -L, but this doesn't seem to give a server name
  3. Use nmap as in the ArchLinux wiki

I'd like to test findsmb but it's not on Fedora for some reason. I'll need to test it before I roll it into the distribution.

#3 Updated by Hammel about 5 years ago

  • % Done changed from 20 to 30

This might be simpler than I thought. I found "findsmb" in the samba source and tried it. It didn't work, but I read the code and found it just called nmblookup. So I tried that with this command line:

nmblookup '*'

And it worked. It gave me the IP address of a local smb client in the first field (space delimited). Since PiBox will run on a closed network with the Media Server providing the smb share this simple command is enough for the Media Player to find the IP of the Media Server and mout its share with this command.

mount -t cifs //<host>/media /mnt/pibox -o user=guest,guest

#4 Updated by Hammel about 5 years ago

  • Priority changed from High to Immediate
  • Severity changed from 03 - Medium to 01 - Critical

#5 Updated by Hammel about 5 years ago

  • Priority changed from Immediate to High
  • % Done changed from 30 to 50
  • Severity changed from 01 - Critical to 03 - Medium
Here's how to set this up:
  1. Write a small program that runs once every X seconds to test for smb shares using nmblookup '*' - a cron job could be used but I'd have to have it run in very short intervals and I'd rather do that within a simple daemon.
  2. If nmblookup finds any hosts, its tries to mount them under /media/<ip>/. If that exists, then the mount attempt is ignored.
  3. After the nmblookup is run, the list of existing mounts should be run to make sure any existing mounts are still valid. If not, the mount is removed.

That should cover it. For efficient sake this program will be written in C. Now that I think about it, it would make sense to add this as a new thread in piboxd.

#6 Updated by Hammel almost 5 years ago

  • % Done changed from 50 to 60

The mount/unmount is implemented in piboxd and seems to work, but the network hiccups make it look like a mount goes away very quickly. This makes mounts bounce up and down very quickly.

There are a number of ways to address this. One is to not test a mount point that is in use (with, possibly, fuser?). Another is to not test a mount point that is younger than a configured time. That would require switching from simple strings in lists to data structures.

Another options is to run nmblookup multiple times so we have a better chance of catching nodes that appear to be missing.

#7 Updated by Hammel almost 5 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 60 to 100

Added support for mounting and unmounting smb shares to piboxd. Interestingly, I found that one of the Pi's with an available share was using a non-RT5370. That machine kept dropping out and coming back. The RT5370 Pi was stable. I'm now very adamant about getting an RT5370-based wifi adapter for all my boxes.

This issue can be closed.

Also available in: Atom PDF