Automatic mounting of volumes on FreeBSD

There are several solutions for automatically mounting volumes. I will introduce you to 2 solutions, automount and DSBMD.

automount

Automount is easy to install and set up. We just install the automount package with pkg. Nothing is needed anymore, as pkg devd will restart after adding new configuration files.

$: doas pkg install automount

So that we can mount further file systems, we install the following packages:

$: doas pkg install exfat-utils fusefs-exfat fusefs-ntfs fusefs-ext2 fusefs-simple-mtpfs fusefs-hfsfuse fusefs-lkl

Finally, we have to enter the following in loader.conf so that the fuse module started when it starts.

$: doas nano /boot/loader.conf =>

fuse_load="YES"

One of the nice features of automount is the log file /var/log/automount.log, which contains all the details about mounted file systems.

$: tail /var/log/automount.log

2018-10-08 12:18:45 /dev/da0s1: mount (fat)
2018-10-08 12:19:23 /dev/da0: detach
2018-10-08 12:19:23 /dev/da0: mount point '/media/da0' removed
2018-10-08 12:19:23 /dev/da0s1: detach
2018-10-08 12:19:23 /dev/da0s1: mount point '/media/da0s1' removed
2018-10-09 11:38:14 /dev/da0: random wait for '0.1' seconds before 'attach' action
2018-10-09 11:38:14 /dev/da0: attach
2018-10-09 11:38:14 /dev/da0: mount (exfat)
2018-10-09 11:44:02 /dev/da0: detach
2018-10-09 11:44:02 /dev/da0: mount point '/media/da0' removed

Automount comes with the configuration file /usr/local/etc/automount.conf which contains the following options on my PC.

$: doas nano /usr/local/etc/automount.conf =>

USERUMOUNT=YES
ATIME=NO
REMOVEDIRS=YES
FM="caja --browser --no-desktop"
USER=daniel
ENCODING=de_DE.UTF-8
CODEPAGE=cp852

It's also a simple solution, and since it's written in POSIX / bin / sh script, it's easy to customize it to suit your needs.

DSBMD & DSBMC

Another possibility to mount drives is dsbmd, dsbmc and dsbmc- cli.

$: doas pkg install dsbmd dsbmc dsbmc-cli

So that we can mount further file systems, we install the following packages:

$: doas pkg install exfat-utils fusefs-exfat fusefs-ntfs fusefs-ext2 fusefs-simple-mtpfs fusefs-hfsfuse fusefs-lkl fusefs-gphotofs

Next, we add the following line to our /etc/rc.conf:

$: doas nano /etc/rc.conf =>

dsbmd_enable="YES"

We then have to enter the following in the autostart of the corresponding Windows manager.

/usr/local/bin/dsbmc -i
/usr/local/bin/dsbmc-cli -a

By default, dsbmd will mount storage devices as regular user. However, we need to make sure that vfs.usermount = 1 is in our /etc/sysctl.conf and is applied.

$: doas nano /etc/sysctl.conf =>

vfs.usermount = 1

Finally, we have to enter the following in loader.conf so that the fuse module is started when it starts.

$: doas nano /boot/loader.conf =>

fuse_load="YES"

After we plug in a FAT32 or exFAT USB device, it is automatically mounted.

The configuration file can be found under /usr/local/etc/dsbmd.conf. The log file can be found under /var/log/dsbmd.log.

$: tail /var/log/dsbmd.log

dsbmd: Killing blocking process 85421 ... on Thu Oct 11 16:48:10 2018
dsbmd: Sending SIGTERM to 85421 ... on Thu Oct 11 16:48:10 2018
dsbmd: Command /usr/local/sbin/mount.exfat $ {DSBMD_DEVICE} "$ {DSBMD_MNTPT}" executed by UID 1000 failed with code 15: No error: 0 on Thu Oct 11 16:48:11 2018
dsbmd: Device /dev/da0 mounted on /media/GKPGE by UID 1000 on Thu Oct 11 16:48:12 2018
dsbmd: Device /dev/da0 unmounted from /media/GKPGE by UID 1000 on Thu Oct 11 16:49:09 2018
dsbmd: Device /dev/da0 mounted on /media/GKPGE by UID 1000 on Thu Oct 11 16:49:15 2018
dsbmd: Device /dev/da0 unmounted from /media/GKPGE by UID 1000 on Thu Oct 11 16:49:16 2018
dsbmd: Client with UID 1000 disconnected on Thu Oct 11 16:52:53 2018
dsbmd: Client with UID 1000 connected on Thu Oct 11 16:52:55 2018
dsbmd: Device /dev/da0 mounted on /media/GKPGE by UID 1000 on Thu Oct 11 16:58:22 2018

The front end of dsbmc looks like this.

Discuss...