DSBMD - a media mounting daemon/automounter for FreeBSD

About

sysutils/dsbmd is a media mounting daemon written for FreeBSD. It detects and monitors storage devices (like USB sticks, hard disks, CD/DVD drives, card readers, digital cameras (PTP), MTP devices like smartphones, tablets etc.), and identifies their filesystems. Its clients can request DSBMD to execute actions on those devices, like mounting and unmounting. Currently supported filesystems are ISO-9660, FAT, NTFS, UFS, Ext[2,3,4]fs, HFS+, exFAT, Btrfs, and XFS.

Installation

# pkg install dsbmd or # cd /usr/ports/sysutils/dsbmd && make install clean

Setup

DSBMD's default configuration works out of the box, and usually doesn't need any modification. Just enable it in /etc/rc.conf and start the daemon:
Code:
# sysrc dsbmd_enable=YES
# service dsbmd start
By default DSBMD mounts storage devices as regular user. This requires the sysctl variable vfs.usermount to be set to 1:

# sysctl vfs.usermount=1

To make this change permanent, set it in /etc/sysctl.conf:

# echo "vfs.usermount=1" >> /etc/sysctl.conf

Members of the [FONT=Courier New]wheel[/FONT] and [FONT=Courier New]operator[/FONT] group are allowed to connect to DSBMD if not configured otherwise. Since mounting of FUSE filesystems as regular user requires privileges from the [FONT=Courier New]operator[/FONT] group, add your username to the group members:

# pw groupmod operator -m yourusername

Notes
  • If you are running hald, it is recommended to stop and disable it:
    Code:
     # service hald stop
     # sysrc hald_enable=NO
Support for ISO-9660, Ext[2,3,4], FAT, NTFS, MTPFS, PTP, and UFS is available by default. Support for additional filesystems can be selected when building from ports, or can be installed afterwards if needed:

exFAT support (optional)

# cd /usr/ports/sysutils/fusefs-exfat && make install clean

HFS+ support (optional)

# cd /usr/ports/sysutils/fusefs-hfsfuse && make install clean

Btrfs and XFS support (optional)

# cd /usr/ports/sysutils/fusefs-lkl && make install clean

Clients

Clients are programs that connect to DSBMD. They query information and ask DSBMD to execute actions, like mounting a device. Currently there are two standard clients you can use (of course you can also choose nc or telnet, but I do not recommend that ;)):
  • sysutils/dsbmc is a desktop environment agnostic GTK+ client for DSBMD that runs in the system tray and lets you mount, unmount, open, play, and eject media by clicking the corresponding device icons or by executing actions from their context menu respectively. Its settings menu allows you to set your preferred file manager and media players for DVDs, audio and video CDs.

    dsbmc-main-screenshot.png
    dsbmc-settings-screenshot.png


    Installation

    # pkg install dsbmc or # cd /usr/ports/sysutils/dsbmc && make install clean

  • sysutils/dsbmc-cli allows you to use all the functions DSBMD provides from the command line. Further, it can be used to realize automounting (see below).

    Examples

    List all attached devices visible to DSBMD

    % dsbmc-cli -l
    dev=/dev/da0:volid=NO_NAME:fsname=msdosfs
    dev=/dev/da1s1:volid=58fd26c81bf4e5ad:fsname=ufs
    dev=/dev/cd0:volid=DVD_VIDEO:fsname=cd9660:type=dvd
    dev=/dev/ugen3.2:volid=GT-I9105P:fsname=mtpfs:type=mtp


    Mount /dev/da0. The device will be mounted to /media/NO_NAME.

    % dsbmc-cli -m /dev/da0

    Eject /dev/cd0

    % dsbmc-cli -e /dev/cd0

    Listen for add events, and automatically play audio CDs and DVDs, where dsbmc-cli replaces %t and %d by device type and device name respectively.

    % dsbmc-cli -L add sh -c 'case %t in audiocd) deadbeef cdda://%d;; dvd) vlc dvd://%d;; esac' \;

    Installation

    # pkg install dsbmc-cli or # cd /usr/ports/sysutils/dsbmc-cli && make install clean

Automount

If you want devices to be automatically mounted by DSBMD, install sysutils/dsbmc-cli, and start dsbmc-cli -a
as regular user. If you also want to let dsbmc-cli automatically play audio CDs, and DVDs as they are inserted, you can extend the command as follows:

% dsbmc-cli -a -L add sh -c 'case %t in audiocd) deadbeef cdda://%d;; dvd) vlc dvd://%d;; esac' \;

To automatically execute dsbmc-cli at session start, add the preferred command to ~/.xinitrc or to your shell's login file. That's it.

Examples for ~/.xinitrc
Code:
#!/bin/sh
dsbmc-cli -a&
exec openbox-session
Code:
#!/bin/sh
dsbmc-cli -a -L add sh -c 'case %t in audiocd) deadbeef cdda://%d;; dvd) vlc dvd://%d;; esac' \;&
exec openbox-session

For more information see http://freeshell.de/~mk/projects/dsbmd.html
 
Last edited:
Dear mrclksr , I have tried the method on a fresh installed FreeBSD 11.1 system under virtualbox. I disabled hald and use dsbmd instead. The ntfs drive can now be mounted. But there were error when I tried to open the drive folder, it said;

'Couldn't execute command "thunar "/media/DriveName"": no such file or directory'

Would you please let me know and point out if I missed something?

Additional info, on this fresh system I install everyhing with pkg. The pkg installed and what i do are as below;
  • freebsd-update fetch install && pkg update
  • virtualbox-ose-additions >> add vboxguest_enable="YES" and vboxservice_enable="YES" on /etc/rc.conf
  • xorg
  • kde >> add dbus_enable="YES" and kdm4_enable="YES" on /etc/rc.conf; add proc /proc procfs rw 0 0 to /etc/fstab
  • dsbmd & dsbmc >> add dsbmd_enable="YES" on /etc/rc.conf; add vfs.usermount=1 on /etc/sysctl.conf
  • reboot
Thanks in advance for your help.
 
But if you are expecting the device to be auto-mounted sysutils/dsbmd is not what you are looking for but vanilla
autofs(5) (see HERE) or sysutils/automount.
No, sysutils/dsbmd supports automounting just fine via sysutils/dsbmc-cli if you really need it (I'd argue that you don't really need it when you have dsbmc). You just need to run this in your session: dsbmc-cli -a

'Couldn't execute command "thunar "/media/DriveName"": no such file or directory'
dsbmc has a setting for this. Under File->Preferences just replace thunar with dolphin (I'm assuming you use KDE) and it should work.
 
Dear lebarondemerde ,
Thanks for trying to help. It was great for a newbie as me to get as much as possible input from more experienced users so I could learn alot.
Previously I successfully auto-mounting my USB (fat32 format) with autofs. But then find problems when tried to mount my portable hdd (ntfs format) in which I regularly backup all my important files there. Tried to search and read within the forums about ntfs, installing fusefs-ntfs but still, there were no solution up till mrclksr redirect me to this link.

Dear tobik@ ,
Many thanks for your instruction to replace thunar with dolphin, it did works and solved my problem. I finally able to transfer file from and to my ntfs external drive in virtualbox.
Later on after I'm getting more confident and could solve some other problem with the touchpad and bugging ath0 bad rate messages, I will then ready to reinstall FreeBSD on my daily working laptop.
 
mrclksr, yesterday I installed sysutils/dsbmd and sysutils/dsbmc-cli, and I use it together with x11-fm/nautilus in an x11-wm/openbox environment.

I found the -L option of dsbmc-cli specially useful for the purpose of deleting the .Trash-<UID> directory which is arbitrarily placed by nautilus when deleting something on the removable media.

In the moment I have in my ~/.xinitrc the following line:
dsbmc-cli -a -L mount rm -rf "%m/.Trash-`id -u`" ';'&
This one deletes the Trash on the next mount, and it works because the action is triggered post factum. Having the remove command triggered by the unmount event does not work in a similar fashion, because in this case it must be executed before the fact, otherwise the mount point has gone already.

Question, would it be somehow possible to reverse the sequence in case of the unmount event or implement sort of a will_unmount event?
 
mrclksr could you add more properties to dsbmixer? Because when I run xprop to find the WM_CLASS can't find it like I'm finding for dsbmd (WM_CLASS(STRING) = "dsbmc", "Dsbmc") and can make the window float in i3wm. Thank and sorry for off topic.
 
Hi Minbari ,
mrclksr could you add more properties to dsbmixer? Because when I run xprop to make find the WM_CLASS can't find it like I'm finding for dsbmd (WM_CLASS(STRING) = "dsbmc", "Dsbmc") and can make the window float in i3wm. Thank and sorry for off topic.
Qt provides no API for doing that, but there is a workaround. Start dsbmixer as follows:
Code:
% dsbmixer -- DSBMixer
 
I read setting the window size fixed will set the window floating in i3. Try this one:
Code:
# cp -r /usr/ports/audio/dsbmixer /tmp && mkdir /tmp/dsbmixer/files && cp patch-mainwin.cpp.txt /tmp/dsbmixer/files
# cd /tmp/dsbmixer && make deinstall clean && make install
 

Attachments

  • patch-mainwin.cpp.txt
    323 bytes · Views: 535
Hello obsigna ,
Question, would it be somehow possible to reverse the sequence in case of the unmount event or implement sort of a will_unmount event?
The big problem is that this is almost impossible if devices are being unmounted without using DSBMD. If DSBMD interaction is guaranteed the protocol can be modified by implementing a will_unmount event and a lock and unlock command.

Best regards,
Marcel
 
mrclksr, thank you very much for looking into this.

I thought already that this might be very difficult without touching devd and the unmount mechanism by the kernel. My actual workaround, i.e. deleting the /.Trash-<UID> on the next mount of a media, is not that bad. And anyway, all this only ment to be a workaround for I am not being able to get x11-fm/nautilus to treat the Trash Can properly on FreeBSD.
 
DSBMD-1.4 released!

Changes since 1.3:
  • Support for bootable USB drives with ISO-9660 has been added. Thanks to jmp-2.
  • Support for nvd(4) and uzip memory disks has been added.
  • Detach md(4) devices when they are ejected.
  • Open listening socket before scanning attached devices, so that clients can connect even if DSBMD is busy with slow devices.
  • Ignore the deprecated [FONT=Courier New]large[/FONT] mount option for [FONT=Courier New]msdosfs[/FONT] on FreeBSD >= 12. This is necessary for users upgrading their system to FreeBSD 12 without adjusting dsbmd.conf. Thanks to Samy Mahmoudi for pointing this out.
 
Hi tankist02,

What are the differences between this and automount and autofs?
I have no experience with autofs/automount(d), so please correct me if I'm wrong:

The autofs/automountd approach is modular, and requires a little bit more configuration. Basically, you have a /media directory under which mountpoints are created. If you plug in a storage device and access /media, a new mountpoint is created, and the device gets mounted on /media/disklabel. autofs/automountd supports NFS, which DSBMD does not.

The DSBMD approach is monolithic, with a simple configuration file, and should work out-of-the-box. It also takes care to load the necessary kernel modules, and makes sure to change the ownership of the mounted devices depending on the user. Unlike autofs/automount(d) DSBMD needs a client to tell it what the user wants.

Which one should I use and why?
I suggest to try both, and see what fits your needs better. For autofs/automountd see ILUXA's Thread autofs-share-your-experience.61251. If you're trying DSBMD with DSBMC and/or DSBMC-Cli, feedback is always welcome :)
 
Hello. First of all, I would like to sincerely thank the developers of this program for their ingeniously simple and functional product that makes life easier for newcomers (and not only). I installed this program today. And here's my impression. External usb-hdd automounted without problems. Same with my Android mobile phone.
 
Thank you, Ogis and rsronin, for your kind comments. It's great to read that someone likes what I do. There have been times I was about to quit, but feedback like yours keeps me working on projects like this. I appreciate that.
 
Code:
dsbmd: *****************************************************************
dsbmd: WARNING
dsbmd: 
dsbmd: Your dsbmd.conf seems to be outdated. Please recreate it from
dsbmd: dsbmd.conf.sample, or merge the files.
dsbmd: 
dsbmd: *****************************************************************
And as it is written, but nothing helped, this inscription appears back when loading. what to do?
 
Code:
dsbmd: *****************************************************************
dsbmd: WARNING
dsbmd:
dsbmd: Your dsbmd.conf seems to be outdated. Please recreate it from
dsbmd: dsbmd.conf.sample, or merge the files.
dsbmd:
dsbmd: *****************************************************************
And as it is written, but nothing helped, this inscription appears back when loading. what to do?
[FONT=courier new]cfgversion[/FONT] wasn't increased in the config file template with the latest release. Just set [FONT=courier new]cfgversion[/FONT] to 1006.
 
Back
Top