This page looks best with JavaScript enabled

Managing removable devices in FreeBSD with dsbmc

 ·  🎃 kr0m

Personally, I have never cared about mounting removable disks via CLI since it is something I do not do frequently. Additionally, allowing regular users to mount file systems will make our system less secure as we will be opening the door to certain types of attacks by users. If the PC is going to be shared with non-technical users, not being able to mount external disks is a problem. In these cases, tools like dsbmc are interesting since they allow us to mount and unmount units graphically.

The user who is going to use dsbmc must be in the operator group:

pw group mod operator -m kr0m

This tool uses QT libraries. To configure the icons to be displayed, we will use qt5ct:

pkg install qt5ct

We install dsbmc:

pkg install dsbmc-cli dsbmc dsbmd

We add the service to the startup:

sysrc dsbmd_enable=YES

We install support for other file systems using FUSE:

pkg install fusefs-gphotofs fusefs-ntfs fusefs-simple-mtpfs fusefs-ext2 fusefs-lkl

We make sure to load FUSE at startup:

vi /boot/loadr.conf

fuse_load=YES

We allow regular users to mount file systems:

vi /etc/sysctl.conf

vfs.usermount=1

As a regular user, we must export the QT_QPA_PLATFORMTHEME environment variable so that the configuration of this tool is read:

export QT_QPA_PLATFORMTHEME=qt5ct
vi .bashrc

export QT_QPA_PLATFORMTHEME=qt5ct

We start the tool to define which icons we want to use:

qt5ct

We must start dsbmc-cli and dsbmc, I do it from my .xinitrc:

vi .xinitrc

# DSB AUTOMOUNTER  
dsbmc-cli -a &  
dsbmc -i &

From here on, we will always manage removable devices from the applet that appears in the notification menu of the WM we use. For example, when we insert a USB, it will appear automatically, and if we double-click it, it will open the disk.

To prevent system devices or internal disks from appearing, we must ignore them by adding them to the list of ignored devices:

When we finish using the disk, it is as simple as right-clicking and selecting Eject.

NOTE: Remember not to use file explorer tools to mount/unmount devices. All management of these devices will always be done from the applet.

If you liked the article, you can treat me to a RedBull here