udev automounting and samba sharing without tools

I recently became reinterested in pogoplug devices when they seemed to have come down to a fairly reliable ten to twenty dollars for the latest models, the kind with an SD slot. They're nice little ARM-based machines with a lovely case and pads for a 3.3 volt serial port. Now I wanted to add a little basic functionality to them when running Debian.

Not long ago, I worked out the finer details of running Debian on the Pogoplug Mobile, a Series 4 pogoplug with USB 2 and no SATA. They're regularly available with the wall wart for ten dollars, so they're still a nice buy if you want to hang some USB devices out in your house someplace. The party piece of Sheevaplug-based computers is the gigabit ethernet, and even the cheapest Pogos have that. The full-fledged pogo with USB3 and SATA can be had for a mere twenty dollars now, and you can even solder a SATA connector (or cable) on to the mobile.

One of the pieces of functionality you'll miss from the otherwise generally pathetic stock pogoplug firmware is automount-and-share, a common feature for cheap consumer network-attached storage (NAS) equipment. The pogoplug is sort of the absolute lowest acceptable rung on the NAS ladder, but only if you replace the stock firmware so that you can just get down to the metal and run something real, like Debian. You could install a package to handle automounting, but you'd still need to add more configuration files to the system to get automatic file sharing via samba. If you have to do that, why not skip using usbmount or autofs and just let udev trigger scripts directly?

Searching about got me to a fairly complete auto-sharing solution based around this idea, but I decided I needed to make additional tweaks. I started with those scripts wholesale, and then added in some bits of scripts cobbled from a page on using usbmount for this task. Et voila, a working solution.

The biggest changes I made were to the samba configuration and to search for a file (called .share) on mounted volumes before sharing them.

Installation

NOTE: This is largely untested and may cause you any sort of problems. It works here but that is not a guarantee that it will work for you.

Installation is relatively simple. Untar/gzip the archive to the root, then either move your /etc/samba/smb.conf to /etc/samba/smb.conf.master and run /etc/samba/mkconf, or just add include = /etc/samba/smb.include.conf to the end of your /etc/samba/smb.conf.

cd /
wget http://hyperlogos.org/files/automount-scripts.tar_.gz
tar xvfz automount-scripts.tar_.gz

then either

mv /etc/samba/smb.conf /etc/samba/smb.conf.master
/etc/samba/mkconf

or

echo "include = /etc/samba/smb.include.conf" >> /etc/samba/smb.conf

Finally, you'll need to make sure the /etc/samba/include.d directory is cleared on each boot.

update-rc.d auto-share-clean defaults

Now, when you insert a device with a formatted partition, it should be mounted to /media/label and if it contains (in the root) a file called ".share" then it shall also be shared via samba. Samba is reloaded when a device is added and restarted when a device is removed; see my source links for more information on the difference.

File attachments: 
AttachmentSize
Binary Data automount-scripts.tar_.gz1.72 KB

Add new comment

(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.

Default

  • Use [fn]...[/fn] (or <fn>...</fn>) to insert automatically numbered footnotes.
  • You may link to images on this site using a special syntax
  • Web page addresses and e-mail addresses turn into links automatically.
  • To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.
  • Internal paths in single or double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or path. Paths to files in single or double quotes, written as "files:somefile.ext", for example, are replaced with the appropriate URL that can be used to download the file.
  • Filtered words will be replaced with the filtered version of the word.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <q>

Issue

  • Lines and paragraphs break automatically.
  • To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>

Drinking Game

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <p> <br> <pre> <h2> <h3> <h4>
  • Images may be embedded like: [image:node_id align=alignment hspace=n vspace=n border=n size=label width=n height=n nolink=(0|1) class=name style=style-data node=id] Leave off any attributes you don't want.
  • [img_assist|...] tags will be displayed, maybe. Please don't make more of them.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.