• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

DSBMD - a media mounting daemon/automounter for FreeBSD

mrclksr

Active Member

Thanks: 103
Messages: 121

#1
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+, and exFAT.

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

Notes
  • If you are running hald, it is recommended to stop and disable it:
    Code:
     # service hald stop
     # sysrc hald_enable=NO
  • Users of dsbmd<1.1 on FreeBSD 12-CURRENT must remove the large option from msdosfs_opts in /usr/local/etc/dsbmd.conf.
exFAT support (optional)

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

HFS+ support (optional)

Since there is no FreeBSD port yet, you have to manually install the FUSE driver for HFS+:
Code:
# git clone https://github.com/0x09/hfsfuse.git && cd hfsfuse
# gmake config WITH_UBLIO=none WITH_UTF8PROC=local
# gmake && gmake install
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.



    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:

mrclksr

Active Member

Thanks: 103
Messages: 121

#3
Hello Beno Kurniawan ,

no problems from KDE users were reported. You can of course try to use hald together with dsbmd. But if there are any problems, disable hald first.
 

Beno Kurniawan

New Member


Messages: 9

#4
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.
 

lebarondemerde

Aspiring Daemon

Thanks: 372
Messages: 984

#5

tobik@

Daemon
Developer

Thanks: 1,184
Messages: 1,775

#6
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.
 

Beno Kurniawan

New Member


Messages: 9

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

obsigna

Aspiring Daemon

Thanks: 338
Messages: 651

#9
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?
 

Minbari

Active Member

Thanks: 72
Messages: 167

#10
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.
 

mrclksr

Active Member

Thanks: 103
Messages: 121

#12
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
 

Minbari

Active Member

Thanks: 72
Messages: 167

#13
Hi Minbari ,

Qt provides no API for doing that, but there is a workaround. Start dsbmixer as follows:
Code:
% dsbmixer -- DSBMixer
Thank you unfortunately it's not working. I'll try to research to find another way to make the window floate.
 

mrclksr

Active Member

Thanks: 103
Messages: 121

#14
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

mrclksr

Active Member

Thanks: 103
Messages: 121

#15
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
 

obsigna

Aspiring Daemon

Thanks: 338
Messages: 651

#16
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.