sysutils/automount - major rewrite and 1.7.0 version

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.

Code:
# 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
 
Dear @vermaden , thanks a lot for all your great work from a happy sysutils/automount (and sysutils/beadm) user. I've tried the 1.7.0 update and works fine with fat and usb. But Im not able to mount mtp (Android) devices anymore. Has something changed?
I think it tries to mount it as cd9660 but I dont know why.
Here is the log:
Code:
2019-08-28 22:04:55 /dev/ugen0.4: attach
2019-08-28 22:04:55 /dev/ugen0.4: not a block device
2019-08-28 22:04:55 /dev/cd1: attach
2019-08-28 22:04:55 /dev/cd1: create '/media/cd1' dir
2019-08-28 22:04:56 /dev/cd1: filesystem mount retry: 1/3
2019-08-28 22:04:57 /dev/cd1: filesystem mount retry: 2/3
2019-08-28 22:04:58 /dev/cd1: filesystem mount retry: 3/3
2019-08-28 22:04:58 /dev/cd1: mount FAIL: 'mount -t cd9660 -e -C=UTF-8 /dev/cd1 /media/cd1'
 
Dear @vermaden , thanks a lot for all your great work from a happy sysutils/automount (and sysutils/beadm) user. I've tried the 1.7.0 update and works fine with fat and usb. But Im not able to mount mtp (Android) devices anymore. Has something changed?
I think it tries to mount it as cd9660 but I dont know why.
Here is the log:
Code:
2019-08-28 22:04:55 /dev/ugen0.4: attach
2019-08-28 22:04:55 /dev/ugen0.4: not a block device
2019-08-28 22:04:55 /dev/cd1: attach
2019-08-28 22:04:55 /dev/cd1: create '/media/cd1' dir
2019-08-28 22:04:56 /dev/cd1: filesystem mount retry: 1/3
2019-08-28 22:04:57 /dev/cd1: filesystem mount retry: 2/3
2019-08-28 22:04:58 /dev/cd1: filesystem mount retry: 3/3
2019-08-28 22:04:58 /dev/cd1: mount FAIL: 'mount -t cd9660 -e -C=UTF-8 /dev/cd1 /media/cd1'
Generally almost everything changed (77% according to GitHub).

I forgot that Android devices sometimes 'publish' their devices as CD-ROM ... I will rework the code and come back with 1.7.1 as soon as possible.

Regards,
vermaden
 
I rarely use them anymore but tried some CDs/DVDs and they show the same error:
Code:
2019-08-28 16:02:25 /dev/cd0: attach
2019-08-28 16:02:31 /dev/cd0: create '/media/cd0' dir
2019-08-28 16:02:34 /dev/cd0: filesystem mount retry: 1/3
2019-08-28 16:02:35 /dev/cd0: filesystem mount retry: 2/3
2019-08-28 16:02:36 /dev/cd0: filesystem mount retry: 3/3
2019-08-28 16:02:36 /dev/cd0: mount FAIL: 'mount -t cd9660 -e -C=UTF-8 /dev/cd0 /media/cd0'

My Android Phone:
Code:
2019-08-28 16:05:39 /dev/ugen0.2: attach
2019-08-28 16:05:39 /dev/ugen0.2: not a block device

From the USB Thumb drives I have, the one with a Linux distro:
Code:
2019-08-28 16:15:31 /dev/ugen0.2: attach
2019-08-28 16:15:31 /dev/ugen0.2: not a block device
2019-08-28 16:15:32 /dev/da0: attach
2019-08-28 16:15:32 /dev/da0: not a block device
2019-08-28 16:15:32 /dev/da0s1: attach
2019-08-28 16:15:33 /dev/da0s1: create '/media/da0s1' dir
2019-08-28 16:15:33 command 'fsck.ext4' not found

fat, exFAT, NTFS, and UFS work fine.
 
Dear @vermaden , thanks a lot for all your great work from a happy sysutils/automount (and sysutils/beadm) user. I've tried the 1.7.0 update and works fine with fat and usb. But Im not able to mount mtp (Android) devices anymore. Has something changed?
I think it tries to mount it as cd9660 but I dont know why.
Here is the log:
Code:
2019-08-28 22:04:55 /dev/ugen0.4: attach
2019-08-28 22:04:55 /dev/ugen0.4: not a block device
2019-08-28 22:04:55 /dev/cd1: attach
2019-08-28 22:04:55 /dev/cd1: create '/media/cd1' dir
2019-08-28 22:04:56 /dev/cd1: filesystem mount retry: 1/3
2019-08-28 22:04:57 /dev/cd1: filesystem mount retry: 2/3
2019-08-28 22:04:58 /dev/cd1: filesystem mount retry: 3/3
2019-08-28 22:04:58 /dev/cd1: mount FAIL: 'mount -t cd9660 -e -C=UTF-8 /dev/cd1 /media/cd1'
Could you send me outputs of these commands please?

Code:
# file -r -b -L -s    /dev/cd1
# file -k -r -b -L -s /dev/cd1
# fstyp               /dev/cd1
# dd if=/dev/cd1 conv=sync count=1 bs=1k 2> /dev/null | strings | head -10
 
I rarely use them anymore but tried some CDs/DVDs and they show the same error:
Code:
2019-08-28 16:02:25 /dev/cd0: attach
2019-08-28 16:02:31 /dev/cd0: create '/media/cd0' dir
2019-08-28 16:02:34 /dev/cd0: filesystem mount retry: 1/3
2019-08-28 16:02:35 /dev/cd0: filesystem mount retry: 2/3
2019-08-28 16:02:36 /dev/cd0: filesystem mount retry: 3/3
2019-08-28 16:02:36 /dev/cd0: mount FAIL: 'mount -t cd9660 -e -C=UTF-8 /dev/cd0 /media/cd0'

My Android Phone:
Code:
2019-08-28 16:05:39 /dev/ugen0.2: attach
2019-08-28 16:05:39 /dev/ugen0.2: not a block device

From the USB Thumb drives I have, the one with a Linux distro:
Code:
2019-08-28 16:15:31 /dev/ugen0.2: attach
2019-08-28 16:15:31 /dev/ugen0.2: not a block device
2019-08-28 16:15:32 /dev/da0: attach
2019-08-28 16:15:32 /dev/da0: not a block device
2019-08-28 16:15:32 /dev/da0s1: attach
2019-08-28 16:15:33 /dev/da0s1: create '/media/da0s1' dir
2019-08-28 16:15:33 command 'fsck.ext4' not found

fat, exFAT, NTFS, and UFS work fine.

Could you send me outputs of these commands please?

Code:
# file -r -b -L -s    /dev/cd0
# file -k -r -b -L -s /dev/cd0
# fstyp               /dev/cd0
# dd if=/dev/cd0 conv=sync count=1 bs=1k 2> /dev/null | strings | head -10

Code:
# file -r -b -L -s    /dev/ugen0.2
# file -k -r -b -L -s /dev/ugen0.2
# fstyp               /dev/ugen0.2
# dd if=/dev/ugen0.2 conv=sync count=1 bs=1k 2> /dev/null | strings | head -10

Code:
# file -r -b -L -s    /dev/da0s1
# file -k -r -b -L -s /dev/da0s1
# fstyp               /dev/da0s1
# dd if=/dev/da0s1 conv=sync count=1 bs=1k 2> /dev/null | strings | head -10
 
Okay. Don't need 1.7.1. Checked the message at my phone and I have only skimmed through 😅.
Anyway, here's the output:

Code:
# file -r -b -L -s /dev/cd1
ISO 9660 CD-ROM filesystem data 'CDROM'

# file -k -r -b -L -s /dev/cd1
ISO 9660 CD-ROM filesystem data 'CDROM' (Lepton 2.x), scale 0-0, spot
sensor temperature 0.000000, unit celsius, color scheme 0, calibration:
offset 0.000000, slope 0.000000 (Lepton 3.x), scale 0-0, spot sensor
temperature 0.000000, unit celsius, color scheme 0, calibration: offset
0.000000, slope 0.000000

# fstyp /dev/cd1
cd9660

# dd if=/dev/cd1 conv=sync count=1 bs=1k 2> /dev/null | strings | head -10
Ambiguous output redirect.
 
This is with an HP printer drivers CD although its the same with any CDROM,DVD+R, -RW, etc.
Code:
$ file -r -b -L -s /dev/cd0
ISO 9660 CD-ROM filesystem data 'HPDJ2520'
$ file -k -r -b -L -s /dev/cd0
ISO 9660 CD-ROM filesystem data 'HPDJ2520' Apple Driver Map, blocksize 2048, blockcount 1158742272, devtype 0, devid 0, driver count 0, contains[@0x200]:
Apple Partition Map, map block count 2, start block 1, block count 63, name Apple, type Apple_partition_map, contains[@0x400]: Apple Partition Map, map block
count 2, start block 517268, block count 279828, name DiscRecording  6.0.4d1, type Apple_HFS, valid, allocated, in use, readable, writable, pic boot code, mount
at startup DOS 2.0 backup id file, sequence 82 (Lepton 2.x), scale 0-0, spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000,
slope 0.000000 (Lepton 3.x), scale 0-0, spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 0.000000
- data
$ fstyp /dev/cd0
cd9660
$ dd if=/dev/cd0 conv=sync count=1 bs=1k 2> /dev/null | strings | head -10

My Android phone:
Code:
$ doas file -k -r -b -L -s /dev/ugen0.2
Password:
ERROR: cannot read `/dev/ugen0.2' (Input/output error)
$ doas fstyp /dev/ugen0.2
Password:
fstyp: /dev/ugen0.2: not a disk

The Linux drive:
Code:
file -r -b -L -s /dev/da0s1
Linux rev 1.0 ext4 filesystem data, UUID=698619e7-7638-4282-b3c1-743acf73e189 (extents) (large files) (huge files)
$ file -k -r -b -L -s /dev/da0s1
Linux rev 1.0 ext4 filesystem data, UUID=698619e7-7638-4282-b3c1-743acf73e189 (extents) (large files) (huge files) (Lepton 2.x), scale 0-0, spot sensor temperature
0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 0.000000 (Lepton 3.x), scale 0-0, spot sensor temperature 0.000000, unit celsius, color scheme
0, calibration: offset 0.000000, slope 0.000000
- data
$ fstyp /dev/da0s1
ext2fs
$ dd if=/dev/da0s1 conv=sync count=1 bs=1k 2> /dev/null | strings | head -10

The dd commands don't give any output.

My phone and the usb drive work well with 1.6.1

The CDs I don't mount them very often and I always do it with mount_cd9660. In fact I tried:
Code:
mount -t cd9660 -e -C UTF-8 /dev/cd0 /media/cd0
mount: illegal option -- e
While
Code:
mount_cd9660 -e -C UTF-8 /dev/cd0 /media/cd0
works fine.
 
Just upgraded a machine to FreeBSD 12 p10, which changed automount from 1.5.8 to 1.7.0. This was a most unpleasent experience:
Looks like automount does depend on Xorg running, otherwise $FM will not be executed. And it does not run $FM as $USER - iike in 1.5.8 - but in sequence for all users that have Xorg running - that is a plain nightmare.

Any chance to get that fixed?
 
Thanks for this input. The 1.7 is generally re-thought of the whole idea of mounting. For example USER is not needed anymore and GROUP is used.

You can revert to old version by fetching the 1.6.1 version by hand:

# fetch -o /usr/local/sbin/automount https://raw.githubusercontent.com/vermaden/automount/1.6.1/automount

I did not had time recently to fix automount more, but I will have some free time after two weeks from now.

Regards.
 
Thank you for the quick fix.

@ "User is not needed any more": My usecaes is this: Server has a RDX drive. When a medium is inserted, a backup is written to it as user "root". WIll this work again with newer versions?
 
I agree, the upgrade was a slight bit of effort.
It appears the LOG parameter in the config-file has changed to LOG_FILE.
Also, I now need to set USER and MNT_GROUP in the config file to get my desired ownership back.
Also, the devd config file gets overwritten on reinstall.

But then, I have to patch the piece anyway, because I also want
1. mounting to a well-defined mountpoint (treated as bareos device) NOT containing the devicename.
2. reporting to syslog

Anyway, it seems to work now just as good as it did before. :)
 
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.
 
how to get it to accept usb external drives??
Code:
Error opening directory “/media/da0s2”: Operation not permitted
I am thinknig something got screwy in v 12.1 now I am unable to automount external drives in my usb port.

dmesg
Code:
ugen0.9: <JMicron External Disk 3.0> at usbus0
umass0 on uhub4
umass0: <JMicron External Disk 3.0, class 0/0, rev 3.00/4.07, addr 11> on usbus0
umass0:  SCSI over Bulk-Only; quirks = 0x8100
umass0:2:0: Attached to scbus2
da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
da0: <JMicron Tech 0407> Fixed Direct Access SPC-4 SCSI device
da0: Serial Number 0000000045A9
da0: 400.000MB/s transfers
da0: 1907729MB (3907029168 512 byte sectors)
da0: quirks=0x2<NO_6_BYTE>
userx@FreeBSD12.1.org:~
log
Code:
$ tail /var/log/automount.log
2019-12-13 09:39:28 /dev/ugen0.9: attach
2019-12-13 09:39:28 command 'simple-mtpfs' not found
2019-12-13 09:39:29 /dev/da0: attach
2019-12-13 09:39:29 ASD
2019-12-13 09:39:29 /dev/da0: not a block device
2019-12-13 09:39:29 /dev/da0s2: attach
2019-12-13 09:39:30 /dev/da0s2: create '/media/da0s2' dir
2019-12-13 09:39:31 /dev/da0s2: fsck.ext4 extdata01: clean, 1094702/122101760 files, 389485909/488378112 blocks
2019-12-13 09:39:31 /dev/da0s2: mount OK: 'ext4fuse /dev/da0s2 /media/da0s2'
2019-12-13 09:39:42 /dev/da0s2: chown '/media/da0s2' dir with 'userx:wheel' rights
in log it says no simple-mtpfs
Code:
$ sudo pkg install simple-mtpfs 
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
pkg: No packages available to install matching 'simple-mtpfs' have been found in the repositories
 
I keep getting between a good mount not permitted when I try opening in a file manager to need to have read write permissions. it is frustrating, and as you showed that is for Phones, not a HDD plugged into the usb port, I can manually mount and it works fine, but that defeats automount.

mount -t ext2fs /dev/da0s1 /mnt
 
@ userxbw

Try using the latest 1.7.1 version of automount and report issues.

Regards.
that was 1.7.1 above post #15 I'll redo and get current results and post back.
setup
17.4.2. Automounting Removable Media

Code:
   /etc/auto_master:
/media        -media        -nosuid

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

/etc/rc.conf
autofs_enable="YES"
# service automount restart
# service devd restart
# service automount start
# service automountd start
# service autounmountd start
# service devd start
Code:
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
Code:
    /etc/devfs.rules:
[localrules=5]
add path 'da*' mode 0660 group operator
/etc/rc.conf:
devfs_system_ruleset="localrules"
    /etc/sysctl.conf:
vfs.usermount=1

# sysctl vfs.usermount=1
vfs.usermount: 0 -> 1

----------
Code:
$ tail /var/log/automount.log
2019-12-13 18:49:07 /dev/ugen0.9: attach
2019-12-13 18:49:07 command 'simple-mtpfs' not found
2019-12-13 18:49:08 /dev/da0: attach
2019-12-13 18:49:08 ASD
2019-12-13 18:49:08 /dev/da0: not a block device
2019-12-13 18:49:08 /dev/da0s2: attach
2019-12-13 18:49:08 /dev/da0s2: create '/media/da0s2' dir
2019-12-13 18:49:09 /dev/da0s2: fsck.ext4 extdata01: clean, 1094699/122101760 files, 389087871/488378112 blocks
2019-12-13 18:49:10 /dev/da0s2: mount OK: 'ext4fuse /dev/da0s2 /media/da0s2'
2019-12-13 18:49:21 /dev/da0s2: chown '/media/da0s2' dir with 'userx:wheel' rights
operation not allowed from file manager.
Code:
Error opening directory “/media/da0s2”: Operation not permitted

Code:
===>>> Checking package repository for latest available version
===>>> Installing package from: /usr/ports/packages/portmaster-download/fusefs-simple-mtpfs-0.3.0_5.txz
Installing fusefs-simple-mtpfs-0.3.0_5...
Extracting fusefs-simple-mtpfs-0.3.0_5: 100%

===>>> Installation of sysutils/fusefs-simple-mtpfs (fusefs-simple-mtpfs-0.3.0_5) complete
still get same error from a file manager.
log says.
Code:
$ tail /var/log/automount.log
2019-12-13 18:56:36 /dev/ugen0.9: attach
2019-12-13 18:56:37 /dev/ugen0.9: no MTP devices found
2019-12-13 18:56:37 /dev/da0: attach
2019-12-13 18:56:37 ASD
2019-12-13 18:56:37 /dev/da0: not a block device
2019-12-13 18:56:37 /dev/da0s2: attach
2019-12-13 18:56:37 /dev/da0s2: create '/media/da0s2' dir
2019-12-13 18:56:38 /dev/da0s2: fsck.ext4 extdata01: clean, 1094699/122101760 files, 389087871/488378112 blocks
2019-12-13 18:56:38 /dev/da0s2: mount OK: 'ext4fuse /dev/da0s2 /media/da0s2'
2019-12-13 18:56:50 /dev/da0s2: chown '/media/da0s2' dir with 'userx:wheel' rights
 
The ext4 is read only, maybe that is why you get the errors?

You are also confusing autofs/automountd from FreeBSD base system with sysutils/automount package ... choose one but not both.
 
The ext4 is read only, maybe that is why you get the errors?

You are also confusing autofs/automountd from FreeBSD base system with sysutils/automount package ... choose one but not both.
thanks for the clairfaction, now I got a sort it out. and ext4 is suppose to be read wirte as of before ver 12.1 I think 12 put that in. thats when I tried FreeBSD again just a few mouths ago, before it upgraded, and I had none of this problem.

how to auto mount in FreeBSD I can see the reason behind the confusion. two different ways, with very similar names, maybe three.

so the 17.4. USB Storage Devices is out?

ah which one supports read write to ext2fs?
 
The ext4 is read only, maybe that is why you get the errors?

You are also confusing autofs/automountd from FreeBSD base system with sysutils/automount package ... choose one but not both.
thanks for the clairfaction, now I got a sort it out. and ext4 is suppose to be read wirte as of before ver 12.1 I think 12 put that in. thats when I tried FreeBSD again just a few mouths ago, before it upgraded, and I had none of this problem.

how to auto mount in FreeBSD I can see the reason behind the confusion. two different ways, with very similar names, maybe three.

so the 17.4. USB Storage Devices is out?

ah which one supports read write to ext2fs?
Code:
Note:
This driver can also be used to access ext3 and ext4 file systems.  The ext2fs(5) filesystem has full read and write support for ext4 as of
FreeBSD 12.0-RELEASE.      Additionally, extended attributes and ACLs are also      supported, while journalling and encryption are not. 
Starting with FreeBSD 12.1-RELEASE, a DTrace provider will be available as well.  Prior versions of FreeBSD can access  ext4 in read and
write mode using sysutils/fusefs-ext2.

is that some kind of separate system?
(soory for mucking up your post)
########### IMPORTANT PART#############
Code:
$ tail /var/log/automount.log
2019-12-14 07:31:38 /dev/da0: attach
2019-12-14 07:31:38 ASD
2019-12-14 07:31:38 /dev/da0: not a block device
2019-12-14 07:31:38 /dev/da0p2: attach
2019-12-14 07:31:38 /dev/da0p2: create '/media/da0p2' dir
2019-12-14 07:31:38 /dev/da0p2: fsck.ext4 You must have r/w access to the filesystem or be root
2019-12-14 07:31:39 /dev/da0p2: filesystem mount retry: 1/3
2019-12-14 07:31:40 /dev/da0p2: filesystem mount retry: 2/3
2019-12-14 07:31:41 /dev/da0p2: filesystem mount retry: 3/3
2019-12-14 07:31:41 /dev/da0p2: mount FAIL: 'ext4fuse /dev/da0p2 /media/da0p2'
after i removed everything I could find on both, then rebooted, redid this automount with the files and binary chmod and restart and that is what I am getting.
Code:
userx@FreeBSD.efi.net:~/Documents/automount-1.7.1
$ id
uid=1000(userx) gid=1000(userx) groups=1000(userx),0(wheel),5(operator),44(video)
running this silly little script I wrote yesturday
Code:
$ cat ~/bin/mntd
#!/usr/bin/env bash

whichdrive=$(ls /dev/da[0-9][a-z]*)
echo $whichdrive
drive=$HOME/drive
fstype=$(fstyp $whichdrive)
echo $fstype

if [[ $fstype = "ext2fs" ]] && [[ -n $whichdrive ]] ; then
        mkdir -p "$drive"
        sudo mount -t ext2fs $whichdrive "$drive"
    fi
ck=$?
if [[ $ck = 1 ]] ; then
    sudo umount "$drive"
    rmdir -v "$drive"
    echo "$? : Unmounted drive"
fi
echo $ck
[ $ck = 0 ] && ls "$drive"


###
$ mntd
/dev/da0p2
0
it gets mounted read / write, but that defets automount'ing a USB Port drive/stick/whatever. Just saying.


I've got two FreeBSDs on this laptop for now, one is using your automount, it is not working as posted in above message for its log?

on the other freebsd os I have autofs setup now removed your automount conf's and automount binary (or script). it is mounting without issues on that one.

I'm going to leave this os with your automount setup so hopefully I can with your help get this sorted out as to why I am not having root privs to mount usb port plugins. why is this showing up?
Code:
2019-12-14 07:31:38 /dev/da0p2: fsck.ext4 You must have r/w access to the filesystem or be root
and how to get rid of it so your automount works on this laptop.
 
Last edited:
Try now with this version:



Code:
# fetch -o /usr/local/sbin/automount https://raw.githubusercontent.com/vermaden/automount/master/automount

# chmod +x /usr/local/sbin/automount
 
Top