FreeBSD Desktop – Part 17 – Configuration – Automount Removable Media

In this article in the FreeBSD Desktop series I will introduce various methods to automatically (or not) mount external/removable devices such as USB or eSATA disks/pendrives or SD/microSD flash cards.

You may want to check other articles in the FreeBSD Desktop series on the FreeBSD Desktop – Global Page where you will find links to all episodes of the series along with table of contents for each episode’s contents.

One of the FreeBSD daemons is devd(8) – the device state change daemon that provides a way to have userland programs run when certain kernel events happen. Such events are when new block device appears/disappears from the /dev directory.

For this problem about 2013 I created a devd(8) based solution – the automount daemon. Its workflow is very simple. When new ada/da/mmcsd* device appears then it tries to detect the filesystems on these partitions/slices and mount them. It you remove such device (device disappears) then it forcefully unmounts it and cleans used mountpoint from the /media directory.

It is available on GitHub - https://github.com/vermaden/automount - and in the FreeBSD Ports as sysutils/automount port. You can also install it as pkg(8) package. Its 2018 and various other solutions appeared in the meantime. One is the included in the FreeBSD base system autofs(8)/automount(8) subsystem.

The other one is dsbmd/dsbmc – a media mounting daemon/automounter for FreeBSD with optional graphical GTK+ frontend. There is also FreeBSD base system solution called autofs(8) which I was not able to make work.

One has to also remember that to mount any FUSE based filesystem the FreeBSD FUSE kernel module needs to be loaded. To enable loading FUSE kernel module at boot add fuse_load=YES line to the /boot/loader.conf file and to load it on the running system just type the kldload fuseΒ command.

Below I will try to compare all their features, strengths and weaknesses.

  • sysutils/automount
    + can customize mount options for each filesystem type
    + written in POSIX /bin/sh script – easy to modify
    + can open selected file manager when device is inserted
    + provides /var/log/automount.log log file
    + supports MTP devices (Android phones for example)
    + supports XFS and HFS
    - does not support BTRFS (can be added)
  • sysutils/dsbmd
    + can customize mount options for each filesystem type
    + supports MTP devices (Android phones for example)
    + provides graphical fronted in GTK+ toolkit
    + can open selected file manager when device is inserted
    + supports BTRFS/HFS/XFS
    + provides /var/log/dsbmd.log log file
    - sometimes hangs at 100% cpu usage
  • autofs(8)
    + supports MTP devices (Android phones for example)
    + is available in the base system
    - does not allow custom mount options per filesystem
    - does not provide log file
    - does not support BTRFS/HFS/XFS (can be added)
    - mount being done only after interaction with /media/* dir
    - removed device is not unmounted automatically

Up to this day I used mine sysutils/automount exclusively as removable devices automount solution. For Android phones I used simple-mtpfs command within xterm(1) terminal. I tried sysutils/dsbmd along with sysutils/dsbmc-cli and GTK+ graphical sysutils/dsbmd frontend and I really liked it but it sometimes fails me with 100% cpu usage and requires restarting. That does not happen withΒ sysutils/automount which just works so I will stick to it but I will provide an update later with results after longer period of testing the sysutils/dsbmd daemon.

sysutils/automount

First I will describe daemon that I used since 2013. The sysutils/automount solution. Its installation and setup is very easy, just add the automount package using pkg(8). Nothing more is needed as the pkg(8) will restart devd(8) after adding new configuration files.

# pkg install automount

One of the nice features of sysutils/automount is /var/log/automount.log log file which has all details about mounted filesystems.

% 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

The sysutils/automount comes with /usr/local/etc/automount.conf configuration file which has these options on my box.

% cat /usr/local/etc/automount.conf
USERUMOUNT=YES
ATIME=NO
REMOVEDIRS=YES
FM="caja --browser --no-desktop"
USER=vermaden
ENCODING=pl_PL.UTF-8
CODEPAGE=cp852

Besides not supporting (yet) MTP devices it just works. It is also very simple solution and being written in POSIX /bin/sh script it is very easy to modify it to one’s needs.

sysutils/dsbmd

The second option is the sysutils/dsbmd solution. Check the links below for more detailed description of this automounting daemon.

To install the dsbmd/dsbmc/dsbmc-cli trio just use pkg(8).

# pkg install dsbmc-cli dsbmc dsbmd

To configure dsbmd/dsbmc/dsbmc-cli trio these steps are needed.

1. Add dsbmd_enable=YES to your /etc/rc.conf file.

2. Install additional filesystems support depending on your needs:

  • fusefs-exfat
  • fusefs-gphotofs
  • fusefs-ntfs
  • fusefs-simple-mtpfs (MTP)
  • fusefs-ext2
  • fusefs-hfsfuse
  • fusefs-lkl

3. Add these lines below to your ~/.xinitrc file (or ~/.xsession).

# DSB AUTOMOUNTER
  dsbmc-cli -a &
  dsbmc &

You will then see the dsbmc icon in the system tray area.

dsbmc-tray

By default dsbmd will mount storage devices as regular user but You need to make sure that vfs.usermount=1 is in your /etc/sysctl.conf file and applied.

After I put the FAT32 or exFAT USB device it was automatically mounted.

/dev/da0 on /media/da0 (msdosfs, local, nosuid, mounted by vermaden)

The configuration file is available at /usr/local/etc/dsbmd.conf location. The dsbmd also comes with /var/log/dsbmd.log log file.

% 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/GMS by UID 1000 on Thu Oct 11 16:48:12 2018
dsbmd: Device /dev/da0 unmounted from /media/GMS by UID 1000 on Thu Oct 11 16:49:09 2018
dsbmd: Device /dev/da0 mounted on /media/GMS by UID 1000 on Thu Oct 11 16:49:15 2018
dsbmd: Device /dev/da0 unmounted from /media/GMS 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/GMS by UID 1000 on Thu Oct 11 16:58:22 2018

The dsbmd can also be configured with many useful options like mount(8) options for each filesystem type separately.

% grep _opts /usr/local/etc/dsbmd.conf | sed 's|\#\ ||g' | awk '{print $1}' | sort -u
cd9660_opts
exfat_opts
ext_opts
ext4_opts
msdosfs_opts
ntfs_opts
ufs_opts

The main GTK+ dsbmc window looks as follows.

dsbmc-prefs.jpg

You can also disable automatic mounting and can mount devices by hand with dsbmc tool.

dsbmc-mount.png

… or unmount them.

dsbmc-unmount.png

It is also a solution used in the NomadBSD portable distribution.

It sometimes fails with 100% cpu usage or with error message as this one:

dsbmc-error

autofs(8)

Last one is the FreeBSD base system solution.

To enable it one should do these steps:

  1. Add autofs_load=YES to your /boot/loader.conf file.
  2. Add autofs_enable=YES to your /etc/rc.conf file.
  3. Uncomment the /media -media -nosuid line in /etc/auto_master file.
  4. In the /etc/devd.conf file you need to add (or uncomment) the following content.
    notify 100 {
      match "system" "GEOM";
      match "subsystem" "DEV";
      action "/usr/sbin/automount -c";
    };
    
  5. To have MTP support you will also have to install sysutils/fusefs-simple-mtpfs and add the /mtp -simple-mtpfs -allow_other line to the /etc/auto_master file. Along with fuse_load=YES in the /boot/loader.conf file.

After doing all these I restarted the autofs(8) daemons.

# grep -r autofs_enable /etc
/etc/rc.d/automountd:rcvar="autofs_enable"
/etc/rc.d/autounmountd:rcvar="autofs_enable"
/etc/rc.d/automount:rcvar="autofs_enable"
/etc/defaults/rc.conf:autofs_enable="NO" # Run autofs daemons.
# /etc/rc.d/automountd onestop
# /etc/rc.d/autounmountd onestop
# /etc/rc.d/automount onestop
# /etc/rc.d/automountd onestart
# /etc/rc.d/autounmountd onestart
# /etc/rc.d/automount onestart

Now after attaching the USB drive the /var/log/messages file shows following information.

# tail /var/log/messages
Nov 21 13:37:42 t420s kernel: ugen2.4:  at usbus2
Nov 21 13:37:42 t420s kernel: umass0 on uhub4
Nov 21 13:37:42 t420s kernel: umass0:  on usbus2
Nov 21 13:37:42 t420s kernel: umass0:  SCSI over Bulk-Only; quirks = 0x8100
Nov 21 13:37:42 t420s kernel: umass0:4:0: Attached to scbus4
Nov 21 13:37:42 t420s kernel: da0 at umass-sim0 bus 0 scbus4 target 0 lun 0
Nov 21 13:37:42 t420s kernel: da0: {USB DISK 3.0 PMAP} Removable Direct Access SPC-4 SCSI device
Nov 21 13:37:42 t420s kernel: da0: Serial Number EC0068F1F89A7D02
Nov 21 13:37:42 t420s kernel: da0: 40.000MB/s transfers
Nov 21 13:37:42 t420s kernel: da0: 14786MB (30283008 512 byte sectors)
Nov 21 13:37:42 t420s kernel: da0: quirks=0x3

When you now check the contents of the /media directory it will contain the da0 dir.

# ls -l /media
total 1
drwxr-xr-x  3 root  wheel  512 2018.11.21 13:37 da0/

The drive/directory is not mounted yet, but when you will try to access that da0 dir (for example display its contents with ls(1) or try to enter it with cd(1) command) then it will get automatically mounted).

# mount | grep media
map -media on /media (autofs)
# ls /media/da0
NLUUG/  OTHER/
# mount | grep media
map -media on /media (autofs)
/dev/da0 on /media/da0 (msdosfs, asynchronous, local, noatime, nosuid, automounted)

After I removed the USB drive the /media/da0 directory remained mounted.

# tail /var/log/messages
Nov 21 13:52:48 t420s kernel: ugen2.4:  at usbus2 (disconnected)
Nov 21 13:52:48 t420s kernel: umass0: at uhub4, port 2, addr 4 (disconnected)
Nov 21 13:52:48 t420s kernel: da0 at umass-sim0 bus 0 scbus4 target 0 lun 0
Nov 21 13:52:48 t420s kernel: da0: {USB DISK 3.0 PMAP}  s/n EC0068F1F89A7D02 detached
Nov 21 13:52:48 t420s kernel: (da0:umass-sim0:0:0:0): Periph destroyed
Nov 21 13:52:48 t420s kernel: umass0: detached
Nov 21 13:52:49 t420s kernel: uhub_reattach_port: giving up port reset - device vanished

The autofs(8) subsystem did not unmounted it automatically.

# mount | grep media
map -media on /media (autofs)
/dev/da0 on /media/da0 (msdosfs, asynchronous, local, noatime, nosuid, automounted)

Of course manual unmounting by hand works (umount /media/da0) but its not what you expect from automounting daemon. It is not very suitable for the desktop usage because of the need to manually ‘access’ the created /media/* directory each time to make it mount.

History

Historically was also sysutils/am-utils – the Berkeley Automounter and Suite of Utilities – and sysutils/automounter which provides scripts to dynamically configure amd(8) daemon.

UPDATE 1 – Make autofs(8) Work

I have reworked the autofs(8) section to make it work. Thanks to the author of the autofs(8) subsystem – trasz – for showing me the source of the problem. The needed entry in the /etc/devd.conf file was missing in the original post. Now it works as advertised, at least for mounting. I am still not able to make it unmount the directory automatically after USB drive removal.

UPDATE 2 – The sysutils/automount 1.5.9 Update

Recently I implemented MTP support (Android phones for example) into the sysutils/automount script. I also added HFS and XFS support. Various fixes and other speed improvements were done (like removal of unneeded __random_wait() function or DELAY time reduction from 1 to just 0.1 second).

The new version is not yet available in the FreeBSD Ports (or packages). Grab it directly from the GitHub page available here:

The ‘manual’ installation is not hard, first built these Ports (or add as packages):

  • sysutils/exfat-utils (for exFAT support)
  • sysutils/fusefs-exfat (for exFAT support)
  • sysutils/fusefs-ntfs (for NTFS read write support)
  • sysutils/fusefs-ext4fuse (for EXT4 support)
  • sysutils/fusefs-simple-mtpfs (for MTP support)
  • sysutils/fusefs-hfsfuse (for HFS support)
  • sysutils/fusefs-lkl (for XFS support)

Then download automount/automount.conf/automount_devd.conf files from GitHub page. Put them into appropriate places and make automount executable. Then restart the devd(8) daemon.

# fetch https://raw.githubusercontent.com/vermaden/automount/master/automount
# fetch https://raw.githubusercontent.com/vermaden/automount/master/automount.conf
# fetch https://raw.githubusercontent.com/vermaden/automount/master/automount_devd.conf
# cp automount.conf      /usr/local/etc/automount.conf
# cp automount_devd.conf /usr/local/etc/devd/automount_devd.conf
# cp automount           /usr/local/sbin/automount
# chmod +x               /usr/local/sbin/automount
# /etc/rc.d/devd restart

Now plugin Your USB thumb drive and have fun πŸ˜‰

Also forgot one thing, it also requires x11/zenity port or package for MTP.

UPDATE 3 – The sysutils/automount 1.6.1 Update

A new version 1.6.1 of sysutils/automount is available with the following fixes:

  • Fix MBR/msdosfs partition unmount issue.

As its not yet available in the FreeBSD Ports please use manual procedure.

Download and unpack the automount-1.6.1.tar.gz file.

Then copy its files to appropriate places as shown below.

# cp automount.conf      /usr/local/etc/automount.conf
# cp automount_devd.conf /usr/local/etc/devd/automount_devd.conf
# cp automount           /usr/local/sbin/automount
# chmod +x               /usr/local/sbin/automount
# /etc/rc.d/devd restart

UPDATE 4 – Major sysutils/automount 1.7.0 Update

Thanks to Rozhuk Ivan who reworked some of sysutils/automount code the new 1.7.0 version is now ready and available.

The changelog is pretty impressive this time:

  • New options available in automount.conf config file.
  • Filesystem detection/mounting reworked totally with file(1)/dd(1)/fstyp(8) as backends.
  • Notifications are now possible with libnitify(8) library.
  • Automatic detection of DISPLAY variable.
  • New automatic wait for device appearance.
  • New detection if device is a block device.
  • Introduction of CD-ROM support.
  • Automatic detection of File Manager with exo-open(1).
  • Option REMOVEDIRS is deprecated now.
  • Handle ‘-o large’ option for FAT under FreeBSD 11.x and 12.x versions.

As its not yet available in the FreeBSD Ports please use manual procedure.

Download and unpack the automount-1.7.0.tar.gz file.

Then copy its files to appropriate places as shown below.

# cp automount.conf      /usr/local/etc/automount.conf
# cp automount_devd.conf /usr/local/etc/devd/automount_devd.conf
# cp automount           /usr/local/sbin/automount
# chmod +x               /usr/local/sbin/automount
# /etc/rc.d/devd restart

UPDATE 5 – Minor sysutils/automount 1.7.1 Update

The major rewrite of sysutils/automount 1.7.0 bring some limitations and problems. This is where 1.7.1 comes with small needed updates.

The changelog is quite small this time:

  • Fixed the mounts with USER option from config file.
  • Made MTP filesystem detection and mount better.
  • Add another check if filesystem is not already mounted.

I have already made a PR so it should be soon available in the FreeBSD Ports.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242405

… but if you want to get it faster, then download and unpack the automount-1.7.1.tar.gz file.

Then copy its files to appropriate places as shown below.

# cp automount.conf      /usr/local/etc/automount.conf
# cp automount_devd.conf /usr/local/etc/devd/automount_devd.conf
# cp automount           /usr/local/sbin/automount
# chmod +x               /usr/local/sbin/automount
# /etc/rc.d/devd restart

Regards.

UPDATE 6 – Minor sysutils/automount 1.7.2 Update

Changelog for this release:

  • Phase out support for sysutils/fusefs-ext4fuse port.
  • Fix UMASK for exFAT filesystems.
  • Fix ISO9660 mount options.

It has already been committed to the FreeBSD Ports tree:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246026

… but if you want to get it faster, then download and unpack the automount-1.7.2.tar.gz file.

Then copy its files to appropriate places as shown below.

# cp automount.conf      /usr/local/etc/automount.conf
# cp automount_devd.conf /usr/local/etc/devd/automount_devd.conf
# cp automount           /usr/local/sbin/automount
# chmod +x               /usr/local/sbin/automount
# /etc/rc.d/devd restart

Regards.

UPDATE 7 – Late sysutils/automount 1.7.9 Update

Changelog since last 1.7.2 release:

  • Fix XORG detection.
  • Implement proposed BLACKLIST_REGEX option.
  • Use sysutils/fusefs-lkl for all ext2/ext3/ext4 mounts.
  • Fix exFAT detection.
  • Fix small problem with checking the mount state.
  • Implement better old directory cleanup.
  • Fix harmless gpart(8) rant about ugen(4) devices.
  • Add option to ignore system partitions like EFI or MSR.
  • Fix mount permissions for FAT filesystems.
  • Added UZIP images support.
  • Added another try to mount device in read only mode.
  • Added optional ada(4) disks support.
  • Added optional md(4) devices support.
  • Added automatic kernel modules loading.
  • Add REMOVEDIRS and NICENAMES options.
  • Use 755 permissions for FAT mounts.
  • Use procstat(1) for faster DISPLAY environment searching.
  • Use 755 instead of 644 to allow scripts execution from removable media.

It has not yet been committed to the FreeBSD Ports tree:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=246026

If you want to get it faster, then download and unpack the automount-1.7.9.tar.gz file.

Then copy its files to appropriate places as shown below.

# cp automount.conf      /usr/local/etc/automount.conf
# cp automount_devd.conf /usr/local/etc/devd/automount_devd.conf
# cp automount           /usr/local/sbin/automount
# chmod +x               /usr/local/sbin/automount
# /etc/rc.d/devd restart

Regards.

EOF

52 thoughts on “FreeBSD Desktop – Part 17 – Configuration – Automount Removable Media

  1. Pingback: In Other BSDs for 2018/10/13 – DragonFly BSD Digest

  2. Pingback: FreeBSD desktop (17) | 0ddn1x: tricks with *nix

      1. vermaden Post author

        As I checked I had these lines in /etc/devd.conf file:


        % grep -C 3 automount /etc/devd.conf
        notify 100 {
        match "system" "GEOM";
        match "subsystem" "DEV";
        action "/usr/sbin/automount -c";
        };

        Like

    1. Edward Tomasz Napierala

      Are you sure it’s not in the examples section, though? The examples in that file are somewhat confusing – they are not commented out using ‘#’ signs, but rather with ‘/*’, or something like that, in the beginning.

      Like

      Reply
      1. vermaden Post author

        You are right … seems I need to test it again πŸ™‚


        (...)
        /* EXAMPLES TO END OF FILE
        (...)
        notify 100 {
        match "system" "GEOM";
        match "subsystem" "DEV";
        action "/usr/sbin/automount -c";
        };

        Will update the original post when I will get next stint of ‘free’ time.

        Thanks for pointing that out.

        Like

  3. Pingback: FreeBSD Desktop – Part 2.1 – Install FreeBSD 12 | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  4. Pingback: FreeBSD Desktop – Part 1 – Simplified Boot | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  5. Pingback: FreeBSD Desktop – Part 2 – Install | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  6. Pingback: FreeBSD Desktop – Part 3 – X11 Window System | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  7. Pingback: FreeBSD Desktop – Part 4 – Key Components – Window Manager | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  8. Pingback: FreeBSD Desktop – Part 5 – Key Components – Status Bar | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  9. Pingback: FreeBSD Desktop – Part 6 – Key Components – Task Bar | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  10. Pingback: FreeBSD Desktop – Part 7 – Key Components – Wallpaper Handling | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  11. Pingback: FreeBSD Desktop – Part 9 – Key Components – Keyboard/Mouse Shortcuts | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  12. Pingback: FreeBSD Desktop – Part 14 – Configuration – Tint2 | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  13. Pingback: FreeBSD Desktop – Part 18 – Global Dashboard | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  14. Pingback: Manage Photography the UNIX Way | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  15. Godzilla

    Hello

    I tried your package. It s working pretty well thank you so much
    I have a stupid question, when I do a # mount I can’t see the mountpoint for the USB drive in /media
    I missed something, I searched for almost 3 hours to understand how it’s possible. I checked your code to check the command mount_msdosfs
    and nothing

    Can you help me to understand please ?

    Like

    Reply
      1. Godzilla

        I’m using

        # uname -v
        FreeBSD 12.0-RELEASE-p7 GENERIC
        

        But after double checking I think I have problem with the script because it never mount the USB device

        I found this line in the log

        2019-07-15 16:02:21 /dev/da1s1: random wait for '0.7' seconds before 'attach' action
        2019-07-15 16:02:21 /dev/da1s1: attach
        2019-07-15 16:02:23 /dev/da1s1: fsck_msdosfs ** /dev/da1s1
        2019-07-15 16:02:23 /dev/da1s1: fsck_msdosfs ** Phase 1 - Read and Compare FATs
        2019-07-15 16:02:23 /dev/da1s1: fsck_msdosfs ** Phase 2 - Check Cluster Chains
        2019-07-15 16:02:23 /dev/da1s1: fsck_msdosfs ** Phase 3 - Checking Directories
        2019-07-15 16:02:23 /dev/da1s1: fsck_msdosfs ** Phase 4 - Checking for Lost Files
        2019-07-15 16:02:23 /dev/da1s1: fsck_msdosfs 4 files, 1333904 free (1918377 clusters)
        2019-07-15 16:02:23 /dev/da1s1: mount (fat)
        2019-07-15 16:02:23 /dev/da1s1: duplicated '/var/run/automount.state'
        

        And when I was removing my device It was trying to remove two mountpoints

        I don’t get this one

        2019-07-15 16:10:52 /dev/da1: detach
        2019-07-15 16:10:52 /dev/da1: mount point '/media/da1' removed
        2019-07-15 16:10:52 /dev/da1s1: detach
        2019-07-15 16:10:52 /dev/da1s1: mount point '/media/da1s1' removed
        

        thank you again for your help

        Like

  16. Pingback: List Block Devices on FreeBSD lsblk(8) Style | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  17. Patricio Villar

    Thank you for your excellent Automount solution! Just one suggestion: Would you mind replacing fusefs-simple-mtpfs with fusefs-jmtpfs? Many users (including myself) have issues with simple-mtpfs as it hangs forever with very high CPU usage, whereas jmtpfs doesn’t have that problem. DSBMD already made the switch btw

    Like

    Reply
    1. vermaden Post author

      Welcome.

      Thank you for suggesting fusefs-jmtpfs as fusefs-simple-mtpfs is broken since quite a long time.

      I will look into it.

      Thanks,
      vermaden

      Like

      Reply
  18. Pingback: FreeBSD GNOME 3 Fast Track | πšŸπšŽπš›πš–πšŠπšπšŽπš—

  19. Graham Perrin

    I look forward to the updated README for your sysutils/automount πŸ‘
    It seems peculiar to me that https://www.freebsd.org/cgi/man.cgi?query=amd&sektion=8&manpath=FreeBSD+12.2-RELEASE+and+Ports#DESCRIPTION mentions autofs(5) and sysutils/am-utils but neither sysutils/automount nor sysutils/dsbmd … I guess that the DESCRIPTION there is intended for people who are interested solely in amd(8).
    As far as I can tell, the upstream Bugzilla for am-utils ceased operating around six years ago. For this reason, and others, I lean heavily towards more modern solutions such as sysutils/automount.
    Given the trio of sysutils/automount, sysutils/dsbmd and autofs(8): is it ever sane to have more than one enabled?

    Like

    Reply
    1. vermaden Post author

      Given the trio of sysutils/automount, sysutils/dsbmd and autofs(8): is it ever sane to have more than one enabled?

      Use just one of them at any time.

      The only exception I know is using sysutils/automount or sysutils/dsbmd for removable media automounting and autofs(8) for automatic NFS mounting.

      Hope that helps.

      Regards.

      Liked by 1 person

      Reply
  20. kr0malfaexploit

    Hello when I attach a USB memory the drive is mounted automatically:

    /dev/da0s2a                           ufs          3.7G    3.4G     76M    98%    /media/da0s2a
    /dev/da0s1                            msdosfs       39M     32M    7.4M    81%    /media/da0s1
    

    But I get strange behaviours:

    Garrus $ ~> id
    uid=1001(kr0m) gid=1001(kr0m) groups=1001(kr0m),0(wheel),5(operator),920(vboxusers)
    
    Garrus $ ~> ls -la /media/
    drwxrwxr-x - root wheel 31 Dec  1979  da0s1
    

    I can write first time:

    Garrus $ ~> echo asd > /media/da0s1/test.txt
    Garrus $ ~> cat /media/da0s1/test.txt
    

    asd

    Garrus $ ~> ls -la /media/da0s1/test.txt
    .rw-r--r-- 4 root wheel 28 Apr 09:24  /media/da0s1/test.txt
    

    But i get error second time:

    Garrus $ ~> echo rrr > /media/da0s1/test.txt
    bash: /media/da0s1/test.txt: Permission denied
    

    Changing USER to kr0m in /usr/local/etc/automount.conf solved the problem, but in that way automount is limited to only one user, I cant share the computer with my sister for example and get automount working for both users?

    Best regards.

    Like

    Reply
    1. vermaden Post author

      Hi,

      if you add your sister user to the wheel group then both of you will be able to write.

      You can also change the wheel group (default) for something else with MNT_GROUP=othergroup in the /usr/local/etc/automount.conf file. Just make sure that both of you are in that othergroup.

      Let me know if it helped.

      Regards.

      Like

      Reply
  21. kr0malfaexploit

    Hello

    If I add the second user to the wheel group it will have the same problem as mine, I can create a file, the file is created with root:wheel ownership, the second try to write to file I get the error: bash: /media/da0s1/test.txt: Permission denied

    Why are my files created with root:wheel owner? should not have been created with the user kr0m?

    Best regards

    Like

    Reply
    1. vermaden Post author

      I just done that – added asd user to my FreeBSD system and added that asd user to the wheel group.

      This new user is perfectly able to edit files I just created with my vermaden user – also in wheel group.

      Its on a FAT32 filesystem pendrive.

      vermaden % id 
      uid=1000(vermaden) gid=1000(vermaden) groups=1000(vermaden),0(wheel),5(operator),44(video),69(network),145(webcamd),920(vboxusers)
      
      vermaden % cd /media/16GB
      
      vermaden % touch asd
      
      vermaden % ls -l
      total 97K
      -rwxrwxr-x 1 vermaden wheel     0 2022-04-29 10:59 asd
      
      vermaden % su - asd
      Password:
      
      asd $ cd /media/16GB/
      
      asd $ echo asd > asd
      
      asd $ id
      uid=999(asd) gid=999(asd) groups=999(asd),0(wheel)
      
      

      The automount(8) uses 775 rights to mount/create files so if you are in wheel group then you can edit them.

      Regards.

      Like

      Reply
  22. kr0malfaexploit

    Hello I have formatted my USB drive with fat32 under Windows OS only for beeing sure its a prestine USB

    Automount mounts my drive with 775 rights:

    Garrus $ ~> cd /media/da0s1/
    Garrus $ /media/da0s1> ls -la
    total 25
    drwxrwxr-x  1 root  wheel  8192 31 dic.   1979 .
    drwxr-xr-x  9 root  wheel     9 28 abr.  08:51 ..
    drwxrwxr-x  1 root  wheel  8192 29 abr.  15:54 System Volume Information
    

    I can generate files:

    Garrus $ /media/da0s1> touch asd
    Garrus $ /media/da0s1> ls -la
    total 25
    drwxrwxr-x  1 root  wheel  8192 31 dic.   1979 .
    drwxr-xr-x  9 root  wheel     9 28 abr.  08:51 ..
    -rw-r--r--  1 root  wheel     0 29 abr.  16:21 asd
    drwxrwxr-x  1 root  wheel  8192 29 abr.  15:54 System Volume Information
    

    But new file is 644 righted with root:wheel ownership, so I cant edit it:

    Garrus $ /media/da0s1> echo bsd > asd
    bash: asd: Permission denied
    

    In your example your new file is 775 righted, why mine not? Maybe I have missing/additional config somewhere in the system?

    My Automount config looks like:

    Garrus $ /media/da0s1> cat /usr/local/etc/automount.conf
    FM="pcmanfm"
    

    Thank you for your explanations and time, I am sorry to be so conflictive.

    Like

    Reply
    1. vermaden Post author

      No problem mate.

      Please try this config and let me know how it went:

      % cat /usr/local/etc/automount.conf
        USERUMOUNT=YES
        USER=kr0m
        FM="pcmanfm"
        NICENAMES=YES
      

      Like

      Reply
  23. kr0malfaexploit

    Hello

    No luck, file is created with 644 rights:

    Garrus $ /media/da0s1> ls -la
    total 25
    drwxrwxr-x  1 kr0m  wheel  8192 31 dic.   1979 .
    drwxr-xr-x  9 root  wheel     9 30 abr.  09:18 ..
    drwxrwxr-x  1 kr0m  wheel  8192 29 abr.  15:54 System Volume Information
    
    Garrus $ /media/da0s1> echo asd > asd
    
    Garrus $ /media/da0s1> ls -la
    total 33
    drwxrwxr-x  1 kr0m  wheel  8192 31 dic.   1979 .
    drwxr-xr-x  9 root  wheel     9 30 abr.  09:18 ..
    -rw-r--r--  1 kr0m  wheel     4 30 abr.  09:19 asd
    

    Now files are generated with kr0m user, but my sister only can read my USB files not write it.

    Best regards.

    Like

    Reply
  24. kr0malfaexploit

    I have changed my umask in .bashrc:

    Garrus $ /media/da0s2> grep umask ~/.bashrc
    umask 0002
    

    Closed terminal and reopened to apply new umask.

    But I get the same results:

    Garrus $ ~> cd /media/da0s2
    Garrus $ /media/da0s2> ls -la
    total 29
    drwxrwxr-x   1 kr0m  wheel  16384 31 dic.   1979 .
    drwxr-xr-x  11 root  wheel     11 30 abr.  14:14 ..
    drwxrwxr-x   1 kr0m  wheel   2048 23 mar.  13:52 boot
    drwxrwxr-x   1 kr0m  wheel   2048 23 mar.  13:52 EFI
    
    Garrus $ /media/da0s2> echo asd > asd
    Garrus $ /media/da0s2> ls -la
    total 31
    drwxrwxr-x   1 kr0m  wheel  16384 31 dic.   1979 .
    drwxr-xr-x  11 root  wheel     11 30 abr.  14:14 ..
    -rw-r--r--   1 kr0m  wheel      4 30 abr.  21:58 asd
    drwxrwxr-x   1 kr0m  wheel   2048 23 mar.  13:52 boot
    drwxrwxr-x   1 kr0m  wheel   2048 23 mar.  13:52 EFI
    

    asd file has 644 not 775 rights.

    I can check that .bashrc configuration was applied:

    Garrus $ /media/da0s2> umask
    0002
    

    Like

    Reply
    1. vermaden Post author

      To be honest with You – I can not find a reason why it works for me and it does not work for you … but if you find that reason – please let me know.

      Like

      Reply
    1. vermaden Post author

      Sure – but I think it will only disappoint you more πŸ™‚

      % id -c
      default
      
      % grep -A 28 '^default' /etc/login.conf
      default:\
              :passwd_format=sha512:\
              :copyright=/etc/COPYRIGHT:\
              :welcome=/var/run/motd:\
              :setenv=BLOCKSIZE=K:\
              :mail=/var/mail/$:\
              :path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin ~/bin:\
              :nologin=/var/run/nologin:\
              :cputime=unlimited:\
              :datasize=unlimited:\
              :stacksize=unlimited:\
              :memorylocked=64K:\
              :memoryuse=unlimited:\
              :filesize=unlimited:\
              :coredumpsize=unlimited:\
              :openfiles=unlimited:\
              :maxproc=unlimited:\
              :sbsize=unlimited:\
              :vmemoryuse=unlimited:\
              :swapuse=unlimited:\
              :pseudoterminals=unlimited:\
              :kqueues=unlimited:\
              :umtxp=unlimited:\
              :priority=0:\
              :ignoretime@:\
              :umask=022:\
              :charset=UTF-8:\
              :lang=C.UTF-8:
      
      % grep umask /etc/login.conf
              :umask=022:\
      #       :umask=022:\
      #       :umask=002:\
      #       :umask=022:\
      #       :umask=022:\
      
      
      
      

      Like

      Reply

Leave a comment