Georg Grabler (STiAT) - blog

Life is like an endlessly recursive fractal of perverse pain and suffering.

Automount with AutoFS

Well, since udev is the “old” way of doing things, and you can run into troubels with Ubuntu 15.04 due to using systemd (fuseblk file systems need mount running in the background, and systemd will kill your mount process after some time), I decided for another solution for my former blog post: AutoFS.

Please note that the current AutoFS in Ubuntu 15.04 has a bug, this is why you’ll need to rebuild the package until a patch is released either by debian or ubuntu upstream. This patch applies to the debian package 5.0.8-2 and the Ubuntu package autofs_5.0.8-1ubuntu3. Fedora and OpenSUSE already do have a patch released, but this post is mostly towards debian/ubuntu users, it should adopt to most other systems as well.

Bug Reports:
Debian bug report
Ubuntu bug report

Patch & Install autofs

apt-get source autofs
cd autofs-5.0.8
vi ./debian/patches/autofs-5.1.0-dont-pass-sloppy-option-for-other-than-nfs-mounts.patch

The patch source can be downloaded from OpenSUSE:

Just Copy/Paste it into the editor and save the file.

Now, you need to edit the ./debian/patches/series and add our patch:

echo "autofs-5.1.0-dont-pass-sloppy-option-for-other-than-nfs-mounts.patch" >> ./debian/patches/series

And of course we need to apply it:

quilt push

Now, we finally can build the package:

dpkg-buildpackage -us -uc -nc

After that, I recommend to install autofs, and patch “over” the original autofs, just expecting Ubuntu/Debian to fix the issue before the next version auf AutoFS:

sudo apt-get install autofs
cd ..
sudo dpkg --install autofs_5.0.8-1ubuntu3_amd64.deb

Now, your AutoFS is without the bug and you can start with your configuration.

UDEV configuration
As in my previews blog post, I want the filesystem to be “always the same”. For this, I simply created the /etc/udev/rules.d/00-WD-Elements.rules as follows:

sudo vi /etc/udev/rules.d/99-WD-Elements.rules

and added the following line, which results in a symlink to /dev/Elements:

KERNEL=="sd?1", SUBSYSTEMS=="usb", ATTRS{product}=="Elements 10B8", ATTRS{serial}=="575836314134345334343938",ATTRS{manufacturer}=="Western Digital", SYMLINK+="Elements"

You can find what’s the right configuration by looking at your own device in /dev, with the following command. Note that you see a lot of device nodes / information blocks there, but you may only use two for identifying your device!

udevadm info -n /dev/sdb1 –attribute-walk

To activate your newly created rule, you can use udevadm

sudo udevadm control --reload-rules

If your created SYMLINK does not appear in /dev, your rule is wrong and you need to check this again.

AutoFS configuration
After that we can finally configure AutoFS. By default, the file /etc/auto.master is created, which we use to add our own mtab file:

sudo vi /etc/auto.master

Add the following line, and make sure you have a newline / blank line at the end of the file, otherwhise the configuration can fail!

/media/usb /etc/auto.usb --timeout=5

Now, we need to add the auto.usb file, which actually specifies our mount:

sudo vi /etc/auto.usb

Add the following line, and make sure there is a newline at the end of file again:

Elements -fstype=ntfs-3g,gid=100,dmask=002,fmask=113,utf8,flush,rw,noatime,user :/dev/Elements

For what the options are, I’ll refer you to my previews blog post.

And you’re done. Restart autofs for reloading the configuration, and your device should appear in /media/usb

sudo systemctl restart autofs

There are no comments

Leave a Reply

Your email address will not be published. Required fields are marked *