Automatic mounting of volumes under FreeBSD

Last update: 11.04.2021

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

automount

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

root #: pkg install automount

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

root #: 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 is started when it starts.

root #: 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.

root #: 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 very simple solution, and since it's written in POSIX / bin / sh script, it's very easy to customize it to suit your needs.

DSBMD & DSBMC

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

root #: pkg install dsbmd dsbmc dsbmc-cli

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

root #: 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:

root #: nano /etc/rc.conf =>

dsbmd_enable = "YES"

We are not allowed to start soon. Otherwise problems can arise.

root #: nano /etc.rc.conf =>

hald_enable = "NO"

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 a regular user. However, we need to make sure that vfs.usermount = 1 is in our /etc/sysctl.conf and is applied.

root #: 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.

root #: 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.

root #: 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.

Your E-Mail address will be encrypted before saving the comment. It will only be used to display a gravatar. By submitting your data, you agree that all entered data may be saved and displayed as a comment.