# devd based AUTOMOUNTER



## vermaden (Feb 17, 2012)

Hi,

I have finally made some effort on writing flexible yet very simple automounter for FreeBSD desktop.

Feel free to submit me BUG reports to this thread 

It currently supports these file formats:
-- NTFS requires sysutils/fusefs-ntfs for R/W
-- FAT/FAT32
-- exFAT requires sysutils/fusefs-exfat
-- EXT2
-- EXT3
-- EXT4 requires sysutils/fusefs-ext4fuse
-- UFS

It keeps state of the mounted devices at /var/run/automount.state and logs all activities to /var/log/automount.log file.

The place for the script is at /usr/local/sbin/automount.sh executable.

The only additional configuration it requires is /usr/local/etc/devd/automount_devd.conf file.

I have created repository @ GITHUB here:
https://github.com/vermaden/automount


----------



## vermaden (Feb 18, 2012)

Added a check if ntfs-3g is available, if not then mount_ntfs is used instead.
Added deleting of empty directories at ${MNTPREFIX}.
Added ${MNTPREFIX} to be set to /mnt or /media according to preference
Adddd additional checks for NTFS filesystem with label "FAT".
Adddd additional checks for FAT filesystem with label "NTFS".


----------



## lockdoc (Feb 18, 2012)

Thanks for the effort.

Is the fat mount part able to handle windows utf-16 characters such çŒª and display them correctly under freebsd FreeBSD?


----------



## bbzz (Feb 18, 2012)

Why is this not in howto section?

A question. Is it possible to *geli attach* a USB disk based on its label, and pass locally stored password at the same time? That would be neat.

Thanks!


----------



## lockdoc (Feb 20, 2012)

*fat mount and propper characters*

@vermaden

The following might be an interesting addition to you script.

*background:*
If I create a few files with chinese/japanese names in the filename under windows and then put it onto an USB stick with fat and try to mount it under FreeBSD it will only show rubbish instead of the propper characters (even if all the fonts are installed).

For this reason I have managed a work-around that handles the compatibility by using sysutils/fusefs-fusexmp_fh.

Here is what I do:


```
root> mount_msdosfs -L zh_CN.GBK /dev/msdosfs/device /mnt/tmp
root> fusexmp_fh -oallow_other,modules=iconv:subdir,from_code=GBK,subdir=/mnt/tmp /media/CW-P7EOS-X
```
This will mount the device on /mnt/tmp and fysexmp_fh will take this and does an extra mount on /media/CW-P7EOS-X with the proper encodings.

I have created a script that does this automatically, still the unmount part is missing.

```
#!/usr/local/bin/bash

# path to the actual mount_msdosfs binary
MOUNT_MSDOSFS="/sbin/mount_msdosfs.bak"

# dir where the normal (no unicode) mount will be
TEMP_DIR="/mnt"
LOG_FILE="$TEMP_DIR/mount_msdosfs.log"


MOUNT_ARGS=${@:1:$((${#@} - 2))}	# get all params except the last two 
DEVICE_PATH=${@:$((${#@} - 1)):1}	# get 2nd last param (/dev/name)
DEVICE_NAME=${DEVICE_PATH##*/}		# basename of device
MOUNT_DIR=${@:${#@}}			# get last param (/mount/dir)

TEMP_MOUNT="$TEMP_DIR/$DEVICE_NAME"

echo "all args:    ${@}"          > $LOG_FILE
echo "MOUNT_ARGS:  $MOUNT_ARGS"  >> $LOG_FILE
echo "DEVICE_PATH: $DEVICE_PATH" >> $LOG_FILE
echo "DEVICE_NAME: $DEVICE_NAME" >> $LOG_FILE
echo "MOUNT_DIR:   $MOUNT_DIR"   >> $LOG_FILE
echo "TEMP_MOUNT   $TEMP_MOUNT"  >> $LOG_FILE

### 1.) Create TMP Mount Dir
if test ! -d $TEMP_MOUNT
then
	echo "creating:    $TEMP_MOUNT" >> $LOG_FILE
	mkdir -p $TEMP_MOUNT
	chmod 777 $TEMP_MOUNT
fi

### 2.) Do temporary mount
echo "[1]: $MOUNT_MSDOSFS -L zh_CN.GBK $DEVICE_PATH $TEMP_MOUNT" >> $LOG_FILE
$MOUNT_MSDOSFS -L zh_CN.GBK $DEVICE_PATH $TEMP_MOUNT


### 3.) Do propper mount
if test ! -d $MOUNT_DIR
then
	echo "creating:    $MOUNT_DIR" >> $LOG_FILE
    mkdir -p $MOUNT_DIR
    chmod 777 $MOUNT_DIR
fi

echo "[2]: fusexmp_fh -oallow_other,modules=iconv:subdir,from_code=GBK,subdir=$TEMP_MOUNT $MOUNT_DIR" >> $LOG_FILE
fusexmp_fh -oallow_other,modules=iconv:subdir,from_code=GBK,subdir=$TEMP_MOUNT $MOUNT_DIR
```

The only problem (back in HAL days) was that if I moved mount_msdosfs to another place and renamed the above script to mount_msdosfs (which calls the renamed originall msdos mount) it did not create the same results as if invoked by hand. If the script was called by HAL, all filenames with exotic characters in it did not show up.

I still have the log output here. This output shows me how HAL handled the call and as I can see it does the exact thing as i would do.

```
all args:    -o nosuid -o longnames -u 1002 -L zh_CN.GBK /dev/msdosfs/CW-P7EOS-X /media/CW-P7EOS-X
MOUNT_ARGS:  -o nosuid -o longnames -u 1002 -L zh_CN.GBK
DEVICE_PATH: /dev/msdosfs/CW-P7EOS-X
DEVICE_NAME: CW-P7EOS-X
MOUNT_DIR:   /media/CW-P7EOS-X
TEMP_MOUNT   /mnt/CW-P7EOS-X
[1]: /sbin/mount_msdosfs.bak -L zh_CN.GBK /dev/msdosfs/CW-P7EOS-X /mnt/CW-P7EOS-X
[2]: fusexmp_fh -oallow_other,modules=iconv:subdir,from_code=GBK,subdir=/mnt/CW-P7EOS-X /media/CW-P7EOS-X
```

Anyway the fusexmp_fh might be worse experimenting with.


----------



## vermaden (Feb 20, 2012)

@lockdoc

Thanks for suggestions, it can be added, but would add some complexity to the whole setup.

It may be 'stupid' idea, but I personally keep all my files in en_US.iso8859-1 format, I do not use any 'national/regional' characters at all at filenames.

*CHANGELOG:*

Added check if *ntfsfix* from sysutils/ntfsprogs is available, if yes then try to fix the NTFS filesystem before mounting it.

Added GPL3 License ... just joking  ... added FreeBSD License to the file.

Added '*noatime*' as a default mount option when possible.

Added TIMEOUT so when an 'orphan' STATE file lock remains, it will be deleted after a TIMEOUT.

Added */usr/local/etc/devd/automount_devd.conf* file instead of messing with the base system config at */etc/devd.conf*.

Added config file to be used from */usr/local/etc/automount.conf* file, possible options are (these are defaults):


```
MNTPREFIX="/media"
  LOG="/var/log/automount.log"
  STATE="/var/run/automount.state"
  ENCODING="en_US.ISO8859-1"
  CODEPAGE="cp437"
  DATEFMT="%Y-%m-%d %H:%M:%S"
  USERUMOUNT="NO"
```

My config currently has only these:


```
ENCODING="pl_PL.ISO8859-2"
  CODEPAGE="cp852"
  USERUMOUNT="YES"
```

The USERMOUNT options if set to YES (default to NO) will '*chmod +s /sbin/umount*', so you can click the ^ button on the devices list in NAUTILUS.

These newly mounted devices appear on NAUTILUS sidebar (only with */media* prefix).

But THUNAR and PCMANFM do not do that, you know any other FMs that display mounted thumb drives/devices?

EXAMPLE:


----------



## vermaden (Feb 20, 2012)

Hi,

I removed the state_lock and stat_unlock mechanisms as they appeared to be not needed, I have shuffled with 3 drives all the time and the 'integrity' has not been lost, and it was a lot faster, because the lock always had to wait for the 'slowest' drive (in term of initializing the device, like USB hard drive).

I simplified the 'attach' section a lot, now each filesystem contains only check/fsck (if possible), mount and log info.

I also simplified and improved the 'detach' section a little.

I have added an option to automatically launch the set-up in config file manager (Yes, like in Windows ;p). 

These are options that I currently successfully use for NAUTILUS file manager, You need to set-up all three of them to make it work.


```
POPUP=YES
FM="nautilus --browser --no-desktop"
USER=vermaden
```

My whole config looks like that now:


```
USERUMOUNT=YES
POPUP=YES
FM="nautilus --browser --no-desktop"
USER=vermaden
ENCODING=pl_PL.ISO8859-2
CODEPAGE=cp852
```

All latest updates are available at GITHUB:
https://github.com/vermaden/automount

Regards,
vermaden


----------



## lockdoc (Feb 20, 2012)

vermaden said:
			
		

> It may be 'stupid' idea, but I personally keep all my files in en_US.iso8859-1 format



Sometimes it can't be avoided, for example you download a bunch of mp3's from your favorite Japanese singer and all the names are in Japanese.


----------



## Crivens (Feb 20, 2012)

A lot of work, and highly appreciated!


----------



## graudeejs (Feb 20, 2012)

lockdoc said:
			
		

> Sometimes it can't be avoided, for example you download a bunch of mp3's from your favorite Japanese singer and all the names are in Japanese.



mv(1) lol


----------



## lockdoc (Feb 20, 2012)

graudeejs said:
			
		

> mv(1) lol


1st, try it with a couple of hundred
2nd, if they all show the same number of _ (as replacement char) good luck


----------



## vermaden (Feb 21, 2012)

FAT/NTFS detection improvements.
The 'chown' now uses sets user's group.
MSDOS filesystem is now mounted with -m 644 -M 755 options by default.
Removed POPUP=YES option, just use USER + FM for simplicity.
NTFS filesystem, when mounted by mount_ntfs(8) uses -u and -g options by default.
Even more simplified 'detach' section.


----------



## vermaden (Feb 21, 2012)

Hi, 

I have created a PORT at last, its in the 'port' directory in the usual place:
https://github.com/vermaden/automount/

Its my first PORT so feel free to bash me about my mistakes 

After latest 'commits' I think that its ready for day-to-day use.

To make 'full advantage' of *automount* install these ports:

sysutils/ntfsprogs
sysutils/fusefs-ntfs
sysutils/fusefs-ext4fuse
sysutils/fusefs-exfat

I will try to add these ports as OPTIONS in the Makefile later.

I will have to think about creating a man page through ...

Feel free to submit Your propositions about next changes/development,
because I think that I already created everything 'I' needed. 

Regards,
vermaden


----------



## vermaden (Feb 27, 2012)

Added help page, removed some bugs and added some new features.


```
% automount --help
AUTOMOUNT is a devd(8) based automounter for FreeBSD.

It supports following file systems:
UFS/FAT/exFAT/NTFS/EXT2/EXT3/EXT4

It needs these ports to mount NTFS/exFAT/EXT4 respectively:
 o sysutils/fusefs-ntfs
 o sysutils/fusefs-exfat
 o sysutils/fusefs-ext4fuse

By default it mounts/unmounts all removable media but
it is possible to set some additional options at the
/usr/local/etc/automount.conf config file.

Below is a list of possible options with description.

MNTPREFIX (set to /media by default)
  With this options You can alter the default root
  for mounting the removable media, for example to
  the /mnt directory.

  example: MNTPREFIX="/media"

ENCODING (set to en_US.ISO8859-1 by default)
  Only used with FAT32 mounts, specifies which
  encoding to use at the mount.

  example: ENCODING="pl_PL.ISO8859-2"

CODEPAGE (set to cp437 by default)
  Only used with FAT32 mounts, specifies which
  code page to use at the mount.

  example: CODEPAGE="cp852"

USER (unset by default)
  If set to some username, the mount command will
  chown(1) the mount directory with the user and
  its primary user group. If used with FM option
  allows to launch the specified file manager after
  a successful mount.

  example: USER="vermaden"

FM (unset by default)
  If set to file manager command, the mount will
  launch the specified command after successful
  mount. Works only if USER parameter is also set.

  example: FM="nautilus --browser --no-desktop"

USERUMOUNT (set to NO by default)
  When set to YES it will 'chmod +s /sbin/umount'
  which would allow an USER to unmount the file
  system with their selected file manager.

  example: USERUMOUNT="YES"

ATIME (set to YES by default)
  When set to NO it will mount filesystems with
  noatime options when possible.

  example: ATIME="NO"

REMOVEDIRS (set to NO by default)
  When set to YES it will remove empty directories
  under the used  after device detach.

  example: REMOVEDIRS="YES"
```


----------



## DemoDoG (Feb 29, 2012)

Sorry I have only been doing regular ports installations before, how do I install this as a port? Should I create a folder under /usr/ports and put files in there and do *make install*?


----------



## vermaden (Feb 29, 2012)

This is the easiest way to get it up and running, just download the needed files and put them in right place. The /usr/local/sbin/automount file needs to have executable bit set.

```
# cp automount           /usr/local/sbin/automount
# cp automount.conf      /usr/local/etc/automount.conf
# cp automount_devd.conf /usr/local/etc/devd/automount_devd.conf
# /etc/rc.d/devd restart
```


----------



## phoenix (Mar 3, 2012)

Just to confirm:  with this, you do not need sysutils/hal installed at all?  And can remove it, and recompile everything to no longer depend on it?


----------



## vermaden (Mar 3, 2012)

@phoenix

Yep! 

You do not even need graphical environment ...


----------



## phoenix (Mar 3, 2012)

I've almost got my system recompiled without HAL.  Once that's done, I'll give this a try and see if I can get it to work with Dolphin/Solid in KDE4.


----------



## vermaden (Mar 3, 2012)

Here is a complete list of 'dependencies' ;p

awk
cat
chmod
chown
dd
ext4fuse
file
find
fsck.ext2
fsck.ext3
fsck.ext4
fsck_msdosfs
fsck_ufs
grep
head
id
mkdir
mount
mount.exfat
mount_msdosfs
mount_ntfs
ntfs-3g
sed
sh
strings
su
umount


----------



## vermaden (Mar 4, 2012)

Hi,

After some 'fun' with MP3 players I have made some modifications and fixes.

Here is a list of what's changed:

Fixed bug about inproper exFAT detection, now mounts fine.
Fixed bug about creating mount dirs for all attached devices no matter if needed or not.
Revised 'detach' section, now removes only directory that is unmounted (if enabled of course).
Simplified FAT/NTFS sections, removed additional check as it break some MP3 players default filesystems automount.
The latest 1.3 version can be found here as usual:
https://github.com/vermaden/automount/

Regards,
vermaden


----------



## vermaden (Mar 4, 2012)

Already at 1.3.1 ...

Fixed the 'detach' section (s/PREFIX/MNTPREFIX/g).
Fixed removing directories of manually (properly) unmounted filesystems.


----------



## nemysis (Apr 12, 2012)

Have installed as a local port, wait to be in FreeBSD Ports.

automount works very good thanks 

Use

/usr/local/etc/automount.conf


```
USERUMOUNT=YES
FM="nautilus --browser --no-desktop"
#USER=vermaden
#ENCODING=pl_PL.ISO8859-2
CODEPAGE=cp852


# Personal Settings

USER=user
ENCODING=en_GB.UTF-8
REMOVEDIRS=YES
ATIME=NO
```

Only Nautilus need some more times to umount USB, from CLI works as usual user immediately. And Nautilus doesn't find computer.

Nautilus cannot handle "computer" locations.


Use Fluxbox only, this can be problem but normal use only cli.


----------



## vermaden (Apr 13, 2012)

nemysis said:
			
		

> Have installed as a local port, wait to be in FreeBSD Ports.


The latest, 1.3.1 version is in the Ports for quite long time now.



			
				nemysis said:
			
		

> automount works very good thanks


Good to hear that 



			
				nemysis said:
			
		

> Only Nautilus need some more times to umount USB, from CLI works as usual user immediately. And Nautilus doesn't find computer.
> 
> Nautilus cannot handle "computer" locations.
> 
> ...


It*'*s not automount's nor Fluxbox's fault, it*'*s Nautilus when it's running without GNOME from what I recall.


----------



## pkubaj (Apr 13, 2012)

Can you point me to where it's located? I see only sysutils/automounter.


----------



## vermaden (Apr 13, 2012)

I submited a PR to create/update the Ports tree.


----------



## nemysis (Apr 15, 2012)

Only what not works is automounting CD/DVD.

In /var/log/messages are no messages about CD/DVD.


----------



## vermaden (Apr 15, 2012)

Unfortunately there is no devd event that can be 'caught' to automount CD, ask FreeBSD developers to add a devd event about inserting and removing CD from the drive


----------



## nemysis (Apr 28, 2012)

Congratulation to commit into FreeBSD Ports collection 

sysutils/automount


----------



## frig (May 18, 2012)

Hello there,

*I* try to show my problem as short as possible (with as little detours as possible):

Starting with the thought to enable autmounting on the laptop/netbook of my wife *I* figured out there were several ways to do it, most of them working with HAL and appropriete FAQs or manual-entries or whatever. After figuring out that HAL probably won't work and also isn't required and *I* also read in one post it*'*s deprecated, *I* couldn't then help but feel lost.

Your thread appeared multiple times and *I* always avoided this solution because it requested a somehow, more user-intervention-heavy method (after my try *I* realized it wasn't).

My point:

After setting up everything as expected, it*'*s possible to mount one USB thumbdrive (*I* only have this one to try actually) and it shows up under /media/da0s1 as expected (though the problem exists, that it switches to the appropriate user even though *I*'m logged in) if *I* manually umount it, the directory doesn't vanish (as *I* expected from setting the REMOVEDIR flag) and mounting the device another time fails with no reason (as *I* think). I am aware that there is not enough evidence to catch the murderer but *I* actually don't know which logs you need.

The automount.conf looks like this:

```
USERMOUNT="YES"
ATIME="NO"
REMOVEDIRS="YES"
```

I removed the user and fm-flags, removing the problem of user-switching with them.

The reason should be me, *I*'m missing a piece of documentation or whatever.

mfg frig


----------



## vermaden (May 19, 2012)

frig said:
			
		

> Hello there,


Hi.



			
				frig said:
			
		

> (though the problem exists, that it switches to the appropriate user even though *I*'m logged in)


Can you explain more?



			
				frig said:
			
		

> if *I* manually umount it, the directory doesn't vanish (as *I* expected from setting the REMOVEDIR flag)



It was a problem with some older version, it was fixed in 1.3.1, I uploaded 1.4 today with improvements towards smartphones which attach th device, but the device is ready to use quite a little later. Check it out at the usual GITHUB place: *https://github.com/vermaden/automount/blob/1.4/automount*



			
				frig said:
			
		

> and mounting the device another time fails with no reason (as *I* think).


Mounting from where? Nautilus? Command line? mount(8)?



			
				frig said:
			
		

> I am aware that there is not enough evidence to catch the murderer but *I* actually don't know which logs you need.


Try 1.4 and if you still have issues, I will tell you what I need


----------



## frig (May 20, 2012)

#1 - changing user
The problem with the user-switching occurs only if the USER and FM variables are set in automount.conf.
The automount.conf looked like this:

```
USER="anja"
FM="thunar"
USERMOUNT="YES"
ATIME="NO"
REMOVEDIRS="YES"
```
Everytime I inserted the USB thumbdrive the user switched to the one stated in the automount.conf, it also did this if the user was already logged in, restarting the x-session.
-> Problem didn't occur again after removing the appropriate flags from the automount.conf

#2 - REMOVEDIR
Problem occurred with version 1.3.1. I will test 1.4 once we return home.

#3 - Mounting from:
Mounting from Thunar via clicking and command line using [CMD=]mount -v -t msdosfs /dev/da0s1 /media/flash[/CMD] The 'device busy' error (even though the device was not in use) occurred one or two times between my tries.

As I said above, *I* will try 1.4 once we're home again =D . But I wanted to clarify my sluggish questions.

*T*hanks in advance, frig.


----------



## vermaden (May 20, 2012)

frig said:
			
		

> #1
> 
> (...)
> 
> Everytime I inserted the usb-thumbdrive the user switched to the one stated in the automount.conf, it also did this if the user was already logged in, restarting the x-session.



That is the purpose of that setting, to mount and change the rights to USER and to use specified FM.

What did you think it worked/should work like?



			
				frig said:
			
		

> #2 - REMOVEDIR
> Problem occurred with version 1.3.1. I will test 1.4 once we return home.



I do not remember changing anything in the *remove* part, so probably it will be the same at 1.4.




			
				frig said:
			
		

> #3 - Mounting from:
> Mounting from Thunar via clicking and command line using [CMD=mount]-v -t msdosfs /dev/da0s1 /media/flash[/CMD]. The device busy error (even though the device was not in use) occurred one or two-times between my tries.


Device busy means it's already mounted (probably by *automount*) or the device is not yet ready to mount after insertion.



			
				frig said:
			
		

> As I said above, i will try 1.4 once we're home again =D . But I wanted to clarify my sluggish questions.


Ok, let me know how 1.4 works for you 



			
				frig said:
			
		

> thanks in advance frig


Welcome.


----------



## frig (May 21, 2012)

#1 - USER and FM
I actually thought about these flags, that they do nothing other th*a*n mount the device in the MNTPREFIX with the appropriate permissions, about the FM I was wrong, I actually thought nothing about this flag. The problem itself still persists, it "changes" to the mentioned user even though the user is logged in, restarting the x-session (though killing all beforehand opened applications) and leaving me with a new empty desktop.

#2 - busy device
Probably happened because of my hastened tries.

Actually automount works quite well, I have tested three different USB drives by now, they were all recognized and mounted correctly and even removing the directories worked. (still using version 1.3.1).

Sole problem remaining is with the permissions, the device mounts in /media/flash/* where users have rwx permissions, though the newly created directory has only root permissions (even though USER is set correctly), usermount is possible throughout the system.

Thanks in advance, frig.


----------



## vermaden (May 27, 2012)

frig said:
			
		

> #1 (...) The problem itself still persists, it "changes" to the mentioned user even though the user is logged in, restarting the x-session (though killing all beforehand opened applications) and leaving me with a new empty desktop.


Interesting, nothing like that happens here, you say that after inserting the pendrive it restarts your X11 session?

The code responsible for that looks like that:

```
su - ${USER} -c "env DISPLAY=:0 ${FM} ${MNT} &"
```

... and with these as example:

```
USER=ver
FM=nautilus
MNT=/media/da0s1
```

It just does execute this:  
	
	



```
su - ver -c "env DISPLAY=:0 nautilus /media/da0s1 &"
```

It does not matter which user is logged in, the automount uses the specified in config user.



> #2 - busy device
> Probably happened because of my hastened tries.


I know a problem that *nautilus *sometimes tries to automount again the already mounted filesystem in /media/ANYTHING, I havent found a way to prevent nautilus from that. 



> Sole problem remaining is with the permissions, the device mounts in /media/flash/* where users have rwx permissions, though the newly created directory has only root permissions (even though USER is set correctly), usermount is possible throughout the system.



If you do not set *USER*, then the mount will be made with *root* permissions, if you set USER, then it will *chmod* it to *USER:USERGROUP* at mount, is it not working like that for you?


----------



## serjsk8 (May 29, 2012)

Thank you vermaden, it works great! Mounts the USB drive and CD-ROM with out problems. I have a problem with HAL, it can not mount my DVD-ROM automatically. Your solution saved me!

But I have a question: how then unmount the device? I have to unmount from the command line, is that right?


----------



## vermaden (May 29, 2012)

serjsk8 said:
			
		

> Thank you vermaden!
> It works great!


Welcome 



			
				serjsk8 said:
			
		

> Mount the usb-drive and cd-rom with out problems!


Interesting, automount automounts CD-ROM? Are you sure? I am asking because automount does not support CD9660 CD-ROM filesystem and does not detect it because there are no devd(8) events to detect the CD insertion/removal.



			
				serjsk8 said:
			
		

> I have a problem with HAL, it can not mount my dvd-rom automatically.


My automount does not have anything to do with HAL, it uses FreeBSD's devd(8) instead.



			
				serjsk8 said:
			
		

> How then unmount the device?
> I have to unmount from the command line, is that right?


You can unmount from *nautilus* or from *konqueror* file managers, as well as from the command line with umount command, if you just remove the USB drive without unmounting, then it will be unmounted automatically for you by automount.


----------



## serjsk8 (May 29, 2012)

Hello,


> My automount does not have anything to do with HAL, it uses FreeBSD's devd(8) instead.


Yes, I know. I just wanted to say that my HAL does not mount a CD-ROM when I'm working in KDE4.



> Interesting, automount automounts CD-ROM? Are you sure? I am asking because automount does not support CD9660 CD-ROM filesystem and does not detect it.



Mmmm... But I can see my DVD-ROM when I insert a disk. I inserted the installation disk with FreeBSD 7.2-RELEASE, and the drive is mounted automatically.


```
#uname -a
FreeBSD bsd 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:15:25 UTC 2012     
root@obrian.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
```


```
# cat /etc/rc.conf
powerd_enable="YES"
hald_enable="YES"
dbus_enable="YES"
devd_enable="YES"
automounter_enable=YES
```


```
# pkg_version -v | grep automoun
automounter-1.4.4                   =   up-to-date with port
```


```
# automounter list
label: <iso9660/FreeBSD_Install> from <cd0>
```


```
# ls -l /media
total 8
drwxr-xr-x  2 root  wheel  512 May 29 14:48 dev
drwxr-xr-x  2 root  wheel  512 May 29 14:48 iso9660
bsd# ls -l /media/dev/
total 0
lrwxr-xr-x  1 root  wheel  61 May 29 14:48 cd0 -> /var/run/automounter.amd.mnt/bff50c4e90e79a0df3be09ea2c5ad62e
lrwxr-xr-x  1 root  wheel  61 May 29 14:48 cd0.iso9660 -> /var/run/automounter.amd.mnt/bff50c4e90e79a0df3be09ea2c5ad62e
bsd# ls -l /media/dev/cd0
lrwxr-xr-x  1 root  wheel  61 May 29 14:48 /media/dev/cd0 -> /var/run/automounter.amd.mnt/bff50c4e90e79a0df3be09ea2c5ad62e
bsd# ls -l /media/dev/cd0.iso9660/
total 539
-r--r--r--   6 root  wheel     793 May  1  2009 .cshrc
-r--r--r--   1 root  wheel    1563 May  1  2009 .profile
dr-xr-xr-x  13 root  wheel    2048 May  1  2009 7.2-RELEASE
-r--r--r--   3 root  wheel    6197 May  1  2009 COPYRIGHT
-r--r--r--   1 root  wheel    4877 May  1  2009 ERRATA.HTM
-r--r--r--   1 root  wheel    3514 May  1  2009 ERRATA.TXT
-r--r--r--   1 root  wheel  186567 May  1  2009 HARDWARE.HTM
-r--r--r--   1 root  wheel  114717 May  1  2009 HARDWARE.TXT
-r--r--r--   1 root  wheel   19736 May  1  2009 README.HTM
-r--r--r--   1 root  wheel   14311 May  1  2009 README.TXT
-r--r--r--   1 root  wheel   60037 May  1  2009 RELNOTES.HTM
-r--r--r--   1 root  wheel   31407 May  1  2009 RELNOTES.TXT
dr-xr-xr-x   2 root  wheel    6144 May  1  2009 bin
dr-xr-xr-x   7 root  wheel    4096 May  1  2009 boot
-r--r--r--   1 root  wheel    2048 May  1  2009 boot.catalog
-r--r--r--   1 root  wheel      39 May  1  2009 cdrom.inf
dr-xr-xr-x   2 root  wheel    2048 May  1  2009 dev
-r--r--r--   1 root  wheel    3704 May  1  2009 docbook.css
dr-xr-xr-x  20 root  wheel   12288 May  1  2009 etc
dr-xr-xr-x   2 root  wheel    2048 May  1  2009 floppies
dr-xr-xr-x   3 root  wheel    8192 May  1  2009 lib
dr-xr-xr-x   2 root  wheel    2048 May  1  2009 libexec
dr-xr-xr-x   2 root  wheel    2048 May  1  2009 media
dr-xr-xr-x   2 root  wheel    2048 May  1  2009 mnt
dr-xr-xr-x  61 root  wheel    8192 May  1  2009 packages
dr-xr-xr-x   2 root  wheel    2048 May  1  2009 proc
dr-xr-xr-x   2 root  wheel   16384 May  1  2009 rescue
dr-xr-xr-x   2 root  wheel    2048 May  1  2009 root
dr-xr-xr-x  60 root  wheel    8192 May  1  2009 rr_moved
dr-xr-xr-x   2 root  wheel   16384 May  1  2009 sbin
lr-xr-xr-x   1 root  wheel       7 May  1  2009 stand -> /rescue
lr-xr-xr-x   1 root  wheel      11 May  1  2009 sys -> usr/src/sys
dr-xr-xr-x   2 root  wheel    2048 May  1  2009 tmp
dr-xr-xr-x  13 root  wheel    2048 May  1  2009 usr
dr-xr-xr-x  21 root  wheel    4096 May  1  2009 var
```

Maybe I'm doing something wrong, and the automounter does not "participate in the game"?


----------



## vermaden (May 29, 2012)

@serjsk8

You confused sysutils/automount (mine) with sysutils/automounter which is amd(8) wrapper (not mine).


----------



## serjsk8 (May 29, 2012)

Oooohhhh!!
You're right, I was wrong.
Excuse me!


----------



## pkubaj (May 29, 2012)

Can you explain why automount is better than automounter?


----------



## vermaden (May 30, 2012)

I haven't tried automounter yet


----------



## Crivens (Nov 30, 2012)

Ok, I need to report something.

After installing this automounter I did not use it for some time. These days I plugged in a USB drive and tried to mount it, only to find I was not allowed. While doing this as root, I found that a bit strange and suspected the last update to have gone a bit sideways. There is the device node, there is the mount point, but I was not able to mount it.

Checked for logged errors, none.
Checked for file system mismatches, none found.
Then it dawned on me that I was not allowed to mount something that was already mounted.

This then was confirmed by carefully reading the output of 'mount'.

HOW DARE YOU release something that simply works without bells, whistles, trumpets and brass band? 

Simply putting software onto the unsuspecting user which works over complete updates, does not complain, does not advertise it's existence, which simply does one thing and does it well.

I have to confess that it took me some minutes to find your automounter again because I totally forgot about it.

In short: Well Done!


----------



## vermaden (Dec 3, 2012)

@Crivens

Thanks 

There were no BUG requests, so I did not upload new versions.


----------



## ORTO-DOX (Dec 3, 2012)

*vermaden*, Thank You for well working *automounter*
I have a little feature request:
Can you add possibility to mount co-existed partitions on the disk. For example, I have Windows + FreeBSD on disk, and when I boot in FreeBSD it is not mounts Windows partition, only new-inserted disks.
Thank you!


----------



## vermaden (Dec 3, 2012)

@ORTO-DOX

Thanks 

There is automounter and automount in the Ports.

I have written/maintain automount which has nothing to do with automounter.

I made automount to mount every partition/device that appears in the /dev after device attach.

Is it possible that You use automounter and not 'my' automount?


----------



## ORTO-DOX (Dec 3, 2012)

)) Sorry for mistake 
I have automount ofcourse.
And as You say it mounts _every partition/device that appears in the /dev after device attach._, but it not mount partition which exists permanently in system.
As I think, automount triggers on devd events, and as permanently exists in system partitions it does not react to


----------



## vermaden (Dec 3, 2012)

ORTO-DOX said:
			
		

> but it not mount partition which exists permanently in system.


Just put that into the /etc/fstab and set the mountpoint to the /media/something, so You will have that filesystem available in the *nautilus*/*konqueror*/*pcmanfm* panel.



			
				ORTO-DOX said:
			
		

> As I think, automount triggers on devd events, and as permanently exists in system partitions it does not react to


Yup.


----------



## Crivens (Dec 3, 2012)

vermaden said:
			
		

> @Crivens
> 
> Thanks
> 
> There were no BUG requests, so I did not upload new versions.



Damn! No brass band plugin which posts the contents of my USB drives to my FailBook wall. 
That is a feature reserved for you-know-who :e


----------



## vermaden (Dec 4, 2012)

@Crivens

Nice one


----------



## pacija (Jan 8, 2013)

Is there a possibility to ignore certain devices? I am testing booting from USB stick (only /boot partition) with rest of the system on geli-encrypted disk. Since I installed automount (which works perfectly besides this, and thank you for providing it), it tries to mount already mounted da0p2 (which holds unencrypted /boot), and fscks it. It doesn't cause much trouble besides annoying warning in dmesg, but it would be nice to have certain device ignore option.


----------



## vermaden (Jan 9, 2013)

pacija said:
			
		

> Is there a possibility to ignore certain devices? I am testing booting from USB stick (only /boot partition) with rest of the system on geli-encrypted disk. Since I installed automount (which works perfectly besides this, and thank you for providing it), it tries to mount already mounted da0p2 (which holds unencrypted /boot), and fscks it. It doesn't cause much trouble besides annoying warning in dmesg, but it would be nice to have certain device ignore option.


Interesting, I will check how to add simple IGNORE list to the config list.


----------



## vermaden (Jan 10, 2013)

@*pacija*

I had to refresh my 'knowledge' on what exactly automount does 

The automount checks if the device is already mounted, but I extended it to also check if something else is mounted in the 'to mount' generated directory.

So automount (even before this update) checks if /dev/da0p2 is already mounted and exits (of course there may be a BUG that makes that behavior different, to the fsck(8) point).

Before You update to the newer version, please do for me some debugging by typing these and send me the output back:

```
# /usr/local/sbin/automount da0p2 attach
# sh -x /usr/local/sbin/automount da0p2 attach
```

The sh -x does more debugging output.

I have also updated automount to 1.4.1 here:
https://github.com/vermaden/automount/commit/2f2e95942eb6e1c05acc345bcaafd3175b636249

Its not yet in the Ports tree.


----------



## vermaden (Jan 10, 2013)

The sysutils/automount in the latest 1.4.1 version just hit the ports (thanks Bryan).

Changelog since the 1.3.1 version:


> - Added extended 'already mounted' checking.
> - Added logging of FSCK output to the /var/log/automount.log file.
> - Added error logging of failed mounts with used mount(8) command.
> - Added +s bit for /sbin/mount* when USERUMOUNT is set to YES.
> ...


----------



## pacija (Jan 10, 2013)

vermaden said:
			
		

> @*pacija*
> 
> Before You update to the newer version, please do for me some debugging by typing these and send me the output back:
> 
> ...



Here it is:

```
root@kaa:/ # /usr/local/sbin/automount da0p2 attach
** /dev/da0p2 (NO WRITE)

USE JOURNAL? no

** Skipping journal, falling through to full fsck

SETTING DIRTY FLAG IN READ_ONLY MODE

UNEXPECTED SOFT UPDATE INCONSISTENCY
** Last Mounted on /boot2
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
1362 files, 41923 used, 901235 free (171 frags, 112633 blocks, 0.0% fragmentation)
mount: /media/da0p2: unknown special file or file system
```


```
root@kaa:/ # sh -x /usr/local/sbin/automount da0p2 attach
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin: <cutting it here to preserve forum table>
+ [ da0p2 = -h -o da0p2 = --help -o 2 -eq 0 -o 2 -eq 1 ]
+ [ -f /usr/local/etc/automount.conf ]
+ . /usr/local/etc/automount.conf
+ USERUMOUNT=YES
+ USER=pacija
+ : /media
+ : /var/log/automount.log
+ : /var/run/automount.state
+ : en_US.ISO8859-1
+ : cp437
+ : %Y-%m-%d %H:%M:%S
+ : YES
+ : YES
+ : NO
+ : pacija
+ : 0
+ [ YES = YES ]
+ chmod u+s /sbin/umount
+ DEV=/dev/da0p2
+ ADD=0
+ MNT=/media/da0p2
+ __check_already_mounted /media/da0p2
+ mount
+ grep ' /media/da0p2 '
+ [ YES = NO ]
+ file -b -L -s /dev/da0p2
+ sed -E 's/label:\ \".*\"//g'
+ __create_mount_point /dev/da0p2
+ mkdir -p /media/da0p2
+ [ pacija = 0 ]
+ id -g -n pacija
+ chown pacija:pacija /media/da0p2
+ fsck_ufs -C -y /dev/da0p2
** /dev/da0p2 (NO WRITE)

USE JOURNAL? no

** Skipping journal, falling through to full fsck

SETTING DIRTY FLAG IN READ_ONLY MODE

UNEXPECTED SOFT UPDATE INCONSISTENCY
** Last Mounted on /boot2
** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
1362 files, 41923 used, 901235 free (171 frags, 112633 blocks, 0.0% fragmentation)
+ mount -o /dev/da0p2 /media/da0p2
mount: /media/da0p2: unknown special file or file system
+ __log '/dev/da0p2:mount (ufs)'
+ date '+%Y-%m-%d %H:%M:%S'
+ echo 2013-01-10 23:59:14 /dev/da0p2:mount '(ufs)'
+ [ 0 -eq 1 ]
```

I also have line in fstab:

```
/dev/da0p2		/boot2		ufs		rw	1 1
```

Perhaps it could be relevant?


----------



## vermaden (Jan 11, 2013)

pacija said:
			
		

> Perhaps it could be relevant?


Yup, it is, the new version 1.4.1 has this fixed, use it and tell me how it works for You.

In the automount 1.3.1 there was a check for the mountpoint, not the device, check if its mounted of course:


```
+ chmod u+s /sbin/umount
+ DEV=/dev/da0p2
+ ADD=0
+ MNT=/media/da0p2
[color="Red"]+ __check_already_mounted /media/da0p2[/color]
```

... but as /dev/da0p2 is mounted to /boot2 and /media/da0p2 is not mounted ... it moved along with filesystem detection and then, the fsck.

The 1.4.1 automount check BOTH if the devd(8) appeared device is mounted and also the generated mountpoint.


----------



## pkubaj (Jan 12, 2013)

After the upgrade to 1.4.1 two of my 3 PCs (one running 9.1-STABLE, the other one with 10.0-CURRENT) hang at boot during start of devd daemon. When I hit CTRL-C, it proceeds. On my 3rd PC (with 9.1-RELEASE) it starts as before. Any reason that would happen?
It seems that it interferes with webcamd. When webcamd isn't enabled or automount is uninstalled, it's ok.


----------



## vermaden (Jan 13, 2013)

pkubaj said:
			
		

> After the upgrade to 1.4.1 two of my 3 PCs (one running 9.1-STABLE, the other one with 10.0-CURRENT) hang at boot during start of devd daemon. When I hit CTRL-C, it proceeds. On my 3rd PC (with 9.1-RELEASE) it starts as before. Any reason that would happen?
> It seems that it interferes with webcamd. When webcamd isn't enabled or automount is uninstalled, it's ok.



Please use this as /usr/local/etc/devd/automount_devd.conf file and show me the contents of the generated /root/DEBUG.* logs after the crash.


```
% [color="Blue"][B]cat /usr/local/etc/devd/automount_devd.conf[/B][/color]
notify 200 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/bin/sh -xe /usr/local/sbin/automount $cdev attach >> /root/DEBUG.$cdev.attach 2>&1";
};

notify 200 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/bin/sh -xe /usr/local/sbin/automount $cdev detach >> /root/DEBUG.$cdev.detach 2>&1";
};
```


----------



## pkubaj (Jan 13, 2013)

http://pastebin.com/KhuGyHeb


----------



## vermaden (Jan 14, 2013)

@pkubaj

I do not see anything bad with automount, it just probes device, submit a BUG to the FreeBSD team please.


----------



## pacija (Jan 14, 2013)

1.4.1 solved my problem. Thanks!


----------



## pkubaj (Jan 14, 2013)

It seems that the issue is caused by embedded card reader. The slots from it are in /dev/ as /dev/da*, even though no card is in. automount is trying to mount these, which obviously fails. The option to ignore some devices would help.


----------



## vermaden (Jan 15, 2013)

pacija said:
			
		

> 1.4.1 solved my problem. Thanks!


Good 



			
				pkubaj said:
			
		

> It seems that the issue is caused by embedded card reader. The slots from it are in /dev/ as /dev/da*, even though no card is in. automount is trying to mount these, which obviously fails. The option to ignore some devices would help.



This is not excuse for FreeBSD. No system should panic because something tries to access the devices placed in /dev, its still a BUG and placing a workaround here is not the best solution.

Also, as the card reader uses the same devices as USB disks (/dev/da*) how one can tell the difference?

Submit the FreeBSD Problem Report with as much possible data as You can.


----------



## Niatross (Feb 11, 2013)

*automount "options"*

I noticed the following message after typing "automount " or "automount --help":


```
It needs these ports to mount NTFS/exFAT/EXT4 respectively:
 o sysutils/fusefs-ntfs
 o sysutils/fusefs-exfat
 o sysutils/fusefs-ext4fuse
```

Are you going to make these "options" available when you install the sysutils/automount port or is the user always going to be responsible for installing these ports?

I don't need to install the sysutils/fusefs-ntfs port if I only need to "read" an NTFS partition, correct?

How do you find out what version of sysutils/automount you have installed (other than pkg_info)? Is there a hidden switch (ex: --version")?


----------



## vermaden (Feb 11, 2013)

Niatross said:
			
		

> I noticed the following message after typing "automount " or "automount --help":
> 
> 
> ```
> ...



I should, I will look into other ports and check how to do that.



			
				Niatross said:
			
		

> I don't need to install the sysutils/fusefs-ntfs port if I only need to "read" an NTFS partition, correct?


Correct.

The automount checks if You have ntfs-3g, and if You have it, then it mounts R/W, if not, then uses mount_ntfs and mounts R/O.



			
				Niatross said:
			
		

> How do you find out what version of sysutils/automount you have installed (other than pkg_info)? Is there a hidden switch (ex: --version")?


I did not see a point in adding that, but I can add --version, should be easy to implement


----------



## Niatross (Feb 12, 2013)

I just installed the sysutils/fusefs-ntfs port and now automount does not automatically mount my NTFS partition on my USB flash drive.

Before I installed  the sysutils/fusefs-ntfs port, automount was mounting my NTFS partition (as read-only) just fine.

What has changed?

I did put the following line in my /etc/rc.conf file and rebooted but the NTFS partition on my USB flash drive is not automatically mounting:


```
fusefs_enable="YES"
```

If I run the following command, I have no problem mounting my NTFS partition (as read/write) on my USB flash drive:


```
ntfs-3g /dev/da1s1 /media/da1s1
```


----------



## vermaden (Feb 12, 2013)

Niatross said:
			
		

> What has changed?


Nothing. I use the same setup (have ntfs-3g installed) and it works without any problem.

Put this content as /usr/local/etc/devd/automount_devd.conf file and do /etc/rc.d/devd restart:


```
notify 200 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/bin/sh -xe /usr/local/sbin/automount $cdev attach >> /root/DEBUG.$cdev.attach 2>&1";
};

notify 200 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/bin/sh -xe /usr/local/sbin/automount $cdev detach >> /root/DEBUG.$cdev.detach 2>&1";
};
```

This will create debug output as /root/DEBUG.* files, which You can send me to debug the problem.


----------



## Niatross (Feb 12, 2013)

Vermaden,

Let's cut to the chase here. I could be doing this all wrong. Please give me the exact steps to make this work. I want to use the sysutils/fusefs-ntfs with your automount utilty. Please tell me the files that I need to configure. I don't even know if I need to add the following setting to the /etc/rc.conf file:


```
fusefs_enable="YES"
```

I'm just guessing I need to add this (otherwise I'll get a device error). Anyway, do I need to add the setting (above) to the /etc/rc.conf file?

What other settings do I need to add to /etc/rc.conf to make this work? Also, do I need to create any symbolic links or changes to other configuration files?

Treat me like I am an idiot.

There is absolutely no instructions on how to make this work. Can you give me step-by-step instructions?

Obviously I made "automount" work with the built-in read-only NTFS driver, but I can't get it to work with NTFS-3G. It's probably one setting that I'm missing in one configuration file in order to get it to work. Can you please just verify the steps, before I even try DEBUG troubleshooting.

I shouldn't have to add anything into the /etc/fstab file, right? I didn't have to add anything to the /etc/fstab file when I made automount work with the built-in read-only NTFS driver.


----------



## vermaden (Feb 12, 2013)

@*rohitewebtech*
@*Niatross*

Well gentlemen, this is my setup:

Nothing about fuse/automount in /boot/loader.conf or /etc/fstab file.

Option fusefs_enable=YES in /etc/rc.conf file.

These are my fuse-related packages:

```
% pkg info | grep fuse
fusefs-exfat-1.0.0             Full-featured exFAT FS implementation as a FUSE module
fusefs-ext4fuse-0.1.3,1        EXT4 implementation for FUSE
fusefs-kmod-0.3.9.p1.20080208_11 Kernel module for fuse
fusefs-libs-2.9.2              FUSE allows filesystem implementation in userspace
fusefs-ntfs-2012.1.15          Mount NTFS partitions (read/write) and disk images
```

Also various fsck.ext* from sysutils/e2fsprogs port:

```
% pkg info | grep e2fs
e2fsprogs-1.42.7               Utilities & library to manipulate ext2/3/4 filesystems
e2fsprogs-libuuid-1.42.7       UUID library from e2fsprogs package
```

The instructions to setup automount are:

```
# make -C /usr/ports/sysutils/automount distclean install clean
```


----------



## vermaden (Feb 13, 2013)

Does it work now?


----------



## pacija (Feb 13, 2013)

pkubaj said:
			
		

> The option to ignore some devices would help.



Indeed, I have similar / same problem on a HP Compaq dx 7400 Minitower which comes with card reader that creates da0 - da4 even when there is no card inserted.

I installed automount and newly inserted USB stick got mounted fine as da5s1. Few days later when I rebooted, the boot process stopped after mounting local disks. No hang, no panic, just stood there as it was waiting. It took input from keyboard, but wouldn't continue all the way to the prompt. I had to reboot into single user mode, uninstall automount, and after that system booted fine.


----------



## vermaden (Feb 13, 2013)

pacija said:
			
		

> Indeed, I have similar / same problem on a HP Compaq dx 7400 Minitower which comes with card reader that creates da0 - da4 even when there is no card inserted.
> 
> I installed automount and newly inserted USB stick got mounted fine as da5s1. Few days later when I rebooted, the boot process stopped after mounting local disks. No hang, no panic, just stood there as it was waiting. It took input from keyboard, but wouldn't continue all the way to the prompt. I had to reboot into single user mode, uninstall automount, and after that system booted fine.



Is there a way to check which da* nodes were created by the smart card reader?

A question to FreeBSD developers, why create device nodes (da*) when there is no medium in the reader?


----------



## pacija (Feb 13, 2013)

Maybe it is hardware related. My laptop Asus N53JQ also comes with integrated card reader, but it does not create device nodes until card is inserted. Mentioned HP minitower behaves the same on Windows - it shows volumes ( E: F: G: H: ) even when cards are not inserted.


----------



## vermaden (Feb 13, 2013)

pacija said:
			
		

> Maybe it is hardware related. My laptop Asus N53JQ also comes with integrated card reader, but it does not create device nodes until card is inserted. Mentioned HP minitower behaves the same on Windows - it shows volumes ( E: F: G: H: ) even when cards are not inserted.



I will look into the blacklisting and update the automount with that option, I will post update here when ready.


----------



## vermaden (Feb 13, 2013)

@*pacija*

I have implemented BLACKLIST option, use it like that in the default config /usr/local/etc/automount.conf file:
`BLACKLIST="da0 da3 da1"`

... other valid syntax examples:
`BLACKLIST="da0"`
`BLACKLIST="da0    ada0"`
`BLACKLIST="da0    ada0   da2 da3a da4s1a"`

The latest automount is available here:
https://raw.github.com/vermaden/automount/master/automount

If You have automount-1.4.1 installed from Ports, then do that:
`# fetch -o /usr/local/sbin/automount [url]https://raw.github.com/vermaden/automount/master/automount[/url]`
`# chmod +x /usr/local/sbin/automount`

To test if the update succeed, do that:
`# /usr/local/sbin/automount --version`

If You see this string below, then its ok:

```
automount 1.4.2 2013/02/13
```



Tell me how that works for You please.


----------



## grocha (Feb 13, 2013)

Now with da0 blacklisted I can boot and flash drive mounted.

Thank You vermaden!!!


----------



## wblock@ (Feb 17, 2013)

Personally, I'd rather have a list of devices that the automounter checks, rather than blacklist a bunch of others.  The combination of the two would be useful:


```
DEVICES="da*"
IGNORE="da2 da5"
```

So that would automount all da devices except da2 and da5.


----------



## Niatross (Feb 18, 2013)

vermaden,

Attached are the log files...

Please see post #66 for details on the problem.


----------



## vermaden (Mar 4, 2013)

Lets start with the good news, thanks to Bryan the automount1.4.2 just hit the Ports: http://freshports.org/sysutils/automount

Changelog:
 - Added BLACKLIST option to ignore problematic devices.
 - Implement sleep/wait with TIMEOUT for devices that not appear.
 - Add more useful information to /var/log/automount.log file.




			
				wblock@ said:
			
		

> Personally, I'd rather have a list of devices that the automounter checks, rather than blacklist a bunch of others.  The combination of the two would be useful:
> 
> 
> ```
> ...



The list of devices, that are passed to automount are *[font="Courier New"]configured[/font]* in devd(8) configuration, not in automount:


```
[font="Courier New"]% [color="Blue"][B]cat /usr/local/etc/devd/automount_devd.conf [/B][/color]
notify 100 {
  match "system" "DEVFS";
  match "type" "CREATE";
[B][color="Magenta"]  match "cdev" "(da|mmcsd)[0-9]+";[/color][/B]
  action "/usr/local/sbin/automount $cdev attach";
};

notify 100 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  [B][color="magenta"]match "cdev" "(da|mmcsd)[0-9]+";[/color][/B]
  action "/usr/local/sbin/automount $cdev detach";
};[/font]
```

About IGNORE, it works the way You want it to 



			
				Niatross said:
			
		

> Attached are the log files...
> 
> Please see post #66 for details on the problem.



These two:

```
mount_msdosfs: Unable to load iconv library: Shared object "libiconv.so" not found, required by "mount_msdosfs"
mount_msdosfs: msdosfs_iconv: No such file or directory
```

can be solved by adding these to /boot/loader.conf file:

```
libiconv_load=YES
cd9660_iconv_load=YES
msdosfs_iconv_load=YES
ntfs_iconv_load=YES
udf_iconv_load=YES
```

I am not able to detect NTFS problem (the other attached log).

About that one:

```
+ grep -E '/media/da1s1$' /var/run/automount.state
+ read DEV PROVIDER MNT
grep: /var/run/automount.state: No such file or directory
```

I have added additional check if /var/run/automount.state file exists, now it should be fine.

These changes will be available in automount 1.4.3 (not yet in Ports as 1.4.2 just hit the Ports).type


----------



## Niatross (Mar 5, 2013)

vermaden said:
			
		

> These two:
> 
> ```
> mount_msdosfs: Unable to load iconv library: Shared object "libiconv.so" not found, required by "mount_msdosfs"
> ...


Same" msdosfs" error messages show up after I load the "iconv" lines (above) in my /boot/loader.conf. BTW: I rebooted to make sure they loaded. The kldstat utility shows that they are loaded.



> About that one:
> 
> ```
> + grep -E '/media/da1s1$' /var/run/automount.state
> ...



There is no automount.state file in the "/var/run" directory. There never has been. I've uninstalled your software and re-installed it. Same old thing. Doesn't work. Receiving the same errors. Maybe I need to re-install the operating system. Obviously something is wrong. I am using 9.0-RELEASE-p4.


----------



## vermaden (Mar 5, 2013)

Niatross said:
			
		

> Same" msdosfs" error messages show up after I load the "iconv" lines (above) in my /boot/loader.conf. BTW: I rebooted to make sure they loaded. The kldstat utility shows that they are loaded.


It helped me to solve the problem, worked ever since, I dunno what to track next about that issue, submit a PR?

Do these errors also occur on command line when You try to do the same mount_msdosfs command?



			
				Niatross said:
			
		

> There is no automount.state file in the "/var/run" directory. There never has been.



After reboot there is no /var/run/automount.state file. The file is created when You got a successful mount with automount, later it will exist, can be empty (no mounted external drives) or not. It is definitely not a permissions problem, because automount is run as root (same as devd).



			
				Niatross said:
			
		

> I've uninstalled your software and re-installed it. Same old thing. Doesn't work. Receiving the same errors.
> 
> Maybe I need to re-install the operating system. Obviously...something is wrong. I am using 9.0-RELEASE-p4



Put that into the /usr/local/etc/devd/automount_devd.conf file and restart devd(8):

```
% [color="Blue"][B]cat /usr/local/etc/devd/automount_devd.conf[/B][/color]
notify 200 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/bin/sh -xe /usr/local/sbin/automount $cdev attach >> /root/DEBUG.$cdev.attach 2>&1";
};

notify 200 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/bin/sh -xe /usr/local/sbin/automount $cdev detach >> /root/DEBUG.$cdev.detach 2>&1";
};

%
```


Then remove /root/DEBUG.*.attach and /root/DEBUG.*.detach files and also /var/log/automount.log file.

Then plug in the problematic pendrive/disk, remove it and then send me those logs, both /root/DEBUG* and automount.log (can be PASTEBIN or whatever else).


----------



## segfault (Mar 5, 2013)

In Ports?!?! Whoohoo!
Love your work here, thanks a lot V.


----------



## Niatross (Mar 5, 2013)

vermaden,

A question:

I currently have the following in the /usr/local/etc/devd/automount_devd.conf file:

```
notify 100 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/usr/local/sbin/automount $cdev attach";
};

notify 100 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/usr/local/sbin/automount $cdev detach";
}; does it stay there all the time
```

I thought the following notify 200 lines was a temporary thing that was placed in the /usr/local/etc/devd/automount_devd.conf file to generate some debug files for troubleshooting:


```
notify 200 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/bin/sh -xe /usr/local/sbin/automount $cdev attach >> /root/DEBUG.$cdev.attach 2>&1";
};

notify 200 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/bin/sh -xe /usr/local/sbin/automount $cdev detach >> /root/DEBUG.$cdev.detach 2>&1";
};
```

Once the person is done generating debug files, does that person go back and remove the notify 200 lines and place the original notify 100 lines back into the /usr/local/etc/devd/automount_devd.conf file?


----------



## Niatross (Mar 5, 2013)

vermaden,

Does webcamd interfere with your software?

I have the following error:


```
Cannot 'start' webcamd. Set webcamd_enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'.
```

Why is webcamd even coming up during boot? I didn't load this software. I notice that there is a webcamd.conf file sitting in my /usr/local/etc/devd directory. How did that get there?

How do I get rid of webcamd? I don't even want it. Did some other software that I installed install webcamd?


----------



## Niatross (Mar 5, 2013)

Here are some messages I receive during boot:


```
Cannot 'start' webcamd. Set webcamd_enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'.
mount_msdosfs: Unable to load iconv library: Shared object "libiconv.so" not found, required by "mount_msdosfs"
mount_msdosfs: msdosfs_iconv: No such file or directory
ntfs-3g: No mountpoint is specified.
grep: /var/run/automount.stste: No such file or directory
ntfs-3g: No mountpoint is specified.
```

Meanwhile, when I run the following command after boot, I have no problem mounting my NTFS partition (as read/write) on my USB flash drive:


```
ntfs-3g /dev/da1s1 /media/da1s1
```

Something is stopping your software from automounting my NTFS flash drive at boot.


----------



## Niatross (Mar 5, 2013)

vermaden,

Here are my attached log files...


----------



## vermaden (Mar 6, 2013)

*TL;DR*
There were 2 bugs, one innocent (just error message), second one prevented automount from working if You do not use ATIME=ON. The latest fixed version is available at GITHUB: https://raw.github.com/vermaden/automount/master/automount

*Fastest fix:*

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

*DIFF(s):*

```
https://github.com/vermaden/automount/commit/6475a583f395926b4584a1941d2f30e4a2c37948
```


Now to replies ... 



			
				segfault said:
			
		

> In Ports?!?! Whoohoo!
> Love your work here, thanks a lot V.



Thanks mate.





			
				Niatross said:
			
		

> Once the person is done generating debug files, does that person go back and remove the notify 200 lines and place the original notify 100 lines back into the /usr/local/etc/devd/automount_devd.conf file?


I mislooked that, it does not matter, You can use 100 for both or 200 for both, its just different 'event number'.

From man devd.conf page

```
The â€œnotifyâ€ variable is available inside this statement and contains, a
     value, depending on which system and subsystem that delivered the event.
```



			
				Niatross said:
			
		

> Does webcamd interfere with your software?


Dunno, I never user webcamd, but in theory, it should not interfere.




			
				Niatross said:
			
		

> How do I get rid of webcamd? I don't even want it. Did some other software that I installed install webcamd?


Remove webcamd package? 



			
				Niatross said:
			
		

> mount_msdosfs: Unable to load iconv library: Shared object "libiconv.so" not found, required by "mount_msdosfs"



Interesting, mount_msdosfs does not require libiconv.so library:

```
% ldd $( which mount_msdosfs )
/sbin/mount_msdosfs:
        libkiconv.so.4 => /lib/libkiconv.so.4 (0x80081c000)
        libc.so.7 => /lib/libc.so.7 (0x800a1f000)
```

Maybe You need libiconv package installed? (I have it installed, but dunno if that is needed for automount):

```
% find /usr/local/lib -name libiconv.so
/usr/local/lib/libiconv.so

% pkg which /usr/local/lib/libiconv.so
/usr/local/lib/libiconv.so was installed by package libiconv-1.14
```



			
				Niatross said:
			
		

> ```
> ntfs-3g: No mountpoint is specified.
> grep: /var/run/automount.stste: No such file or directory
> ntfs-3g: No mountpoint is specified.
> ...


This is fixed, check *TL;DR* at the beginning of this post..



			
				Niatross said:
			
		

> Here are my attached log files...
> 
> 
> ```
> ...



Seems like broken filesystem:
http://lists.freebsd.org/pipermail/freebsd-questions/2010-August/220488.html

I would move the data from this drive, create new filesystem with newfs_msdos and try again.




			
				Niatross said:
			
		

> + ntfs-3g -o /dev/da1s1 /media/da1s1
> ntfs-3g: No mountpoint is specified.


You just nailed a BUG (check *TL;DR*) 

The -o option is empty, because ATIME is not disabled, and the code was ntfs-3g -o ${OPTS} so with empty OPTS it failed. Now it is OPTS="-o noatime" and ntfs-3g ${OPTS}.





			
				Niatross said:
			
		

> Why is msdosfs even being used when this flash drive only has one NTFS partition on it?





Could You also provide me output of these commands:

```
# file -b -L -s /dev/da1s1
# file -b -L -s /dev/da1
```


----------



## Niatross (Mar 6, 2013)

The [cmd=]file -b -L -s /dev/da1s1[/FILE][/cmd] command displays the following results:


```
x86 boot sector, code offset 0x52, OEM-ID "NTFS    ", reserved sectors 0, Media descriptor 0xf8, heads 255, hidden sectors 2048, dos < 4.0 BootSector (0x0)
```

The [cmd=]file -b -L -s /dev/da1[/cmd] command displays the following results:


```
x86 boot sector; partition 1: ID=0x7, starthead 32, startsector 2048, 8388608 sectors, code offset 0xc0, OEM-ID "      \320\274", Bytes/sector 190, sectors/cluster 124, reserved sectors 191, FATs 6, root entries 185, sectors 64514 (volumes <=32 MB) , Media descriptor 0xf3, sectors/FAT 20644, heads 6, hidden sectors 309755, sectors 2147991229 (volumes > 32 MB) , physical drive 0x7e, dos < 4.0 BootSector (0x0)
```


----------



## vermaden (Mar 6, 2013)

@*Niatross*

Thanks.

Just to be sure, this da0s1 partition containt NTFS filesystem?

Does the latest automount (from previous post) fixes problems Your problems?


----------



## Niatross (Mar 7, 2013)

vermaden,

Yes. Your latest automount fixes the bug listed above (*TL;DR*).

I also cleared up the following error by creating a new file system:


```
fsck_msdosfs Invalid sector size: 190
```

The only problem left is:


```
+ mkdir -p /media/da1
+ [ 0 != 0 ]
+ __wait_for_device /dev/da1
+ local COUNT=0
+ head -c 1 /dev/da1
+ which ntfs-3g
+ __wait_for_device /dev/da1
+ local COUNT=0
+ head -c 1 /dev/da1
+ ntfs-3g /dev/da1 /media/da1
fuse: failed to open fuse device: No such file or directory
+ __log '/dev/da1: mount failed (ntfs) '\''ntfs-3g  /dev/da1 /media/da1'\'
+ date '+%Y-%m-%d %H:%M:%S'
+ echo 2013-03-06 19:24:14 '/dev/da1: mount failed (ntfs) '\''ntfs-3g  /dev/da1
/media/da1'\'
+ exit 1
```

The error (above) was taken from "DEBUG.da1.attach". This error only occurs during boot. If I stick the NTFS flash drive in after boot, automount mounts the NTFS flash drive and it works fine.

The /var/log/automount.log file displays the following:


```
2013-03-06 19:24:14 /dev/da1: attach
2013-03-06 19:24:14 /dev/da1: mount failed (ntfs) 'ntfs-3g  /dev/da1 /media/da1'
```


```
%kldstat
Id Refs Address            Size     Name
 1   48 0xffffffff80200000 11cdab0  kernel
 2    1 0xffffffff813ce000 8900     vesa.ko
 3    1 0xffffffff813d7000 1190     ntfs_iconv.ko
 4    2 0xffffffff813d9000 efe8     ntfs.ko
 5    5 0xffffffff813e8000 6f40     libiconv.ko
 6    3 0xffffffff813ef000 45058    linux.ko
 7    1 0xffffffff81435000 4bb8     vmxnet.ko
 8    1 0xffffffff8143a000 9aa8     vmxnet3.ko
 9    1 0xffffffff81444000 11c8     cd9660_iconv.ko
10    1 0xffffffff81446000 11d8     msdosfs_iconv.ko
11    1 0xffffffff81448000 1178     udf_iconv.ko
12    2 0xffffffff8144a000 9b18     udf.ko
13    1 0xffffffff81612000 1582     fdescfs.ko
14    1 0xffffffff81614000 429d     linprocfs.ko
15    1 0xffffffff81619000 a058     fuse.ko
16    1 0xffffffff81624000 1e7      linux_adobe.ko
17    1 0xffffffff81625000 1464     vmmemctl.ko
18    1 0xffffffff81627000 2d50     vmblock.ko
```


----------



## vermaden (Mar 7, 2013)

Niatross said:
			
		

> ```
> + ntfs-3g /dev/da1 /media/da1
> fuse: failed to open fuse device: No such file or directory
> ```
> ...



Startup scripts from RCng are started in particular order, this ca be check by rcorder:


```
% [color="RoyalBlue"]rcorder /etc/rc.d/* /usr/local/etc/rc.d/* 2> /dev/null | wc -l[/color]
     183

% [color="royalblue"]rcorder /etc/rc.d/* /usr/local/etc/rc.d/* 2> /dev/null | grep -n fusefs[/color]
116:/usr/local/etc/rc.d/fusefs

% [color="royalblue"]rcorder /etc/rc.d/* /usr/local/etc/rc.d/* 2> /dev/null | grep -n devd[/color]
36:/etc/rc.d/devd
```
... so in short words, there are 183 scripts to be started at boot (on my system), fusefs will be started as 116 but devd will be started earlier as 36 one. So when devd runs automount the FUSE kernel modules are not yet loaded because they are to be loaded later, and hence the error.

There is sollution for this, add fuse_load=YES to /boot/loader.conf so the FUSE subsystem kernel module will be loaded before devd starts its existenece at boot.


----------



## Niatross (Mar 7, 2013)

I ran the following command and received an "ambiguous output redirect" error:


```
rcorder /etc/rc.d/* /usr/local/etc/rc.d/* 2> /dev/null | wc -l
```

Anyway, I placed "fuse_load=YES" in the "/boot/loader.conf" file and rebooted the system and "automount" still does not mount my NTFS flash drive on startup.


----------



## SirDice (Mar 7, 2013)

Redirection works differently with csh(1).


----------



## vermaden (Mar 7, 2013)

Niatross said:
			
		

> I ran the following command and received an "ambiguous output redirect" error


This is because You use CSH/TCSH shell, the CSH/TCSH shell is kinda retarded:
http://www.shlomifish.org/open-source/anti/csh/
http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/
http://www.grymoire.com/Unix/CshTop10.txt
http://www-uxsup.csx.cam.ac.uk/misc/csh.html



			
				Niatross said:
			
		

> Anyway, I placed "fuse_load=YES" in the "/boot/loader.conf" file and rebooted the system and "automount" still does not mount my NTFS flash drive on startup.


What does automount logs say now?


----------



## Niatross (Mar 7, 2013)

> What does automount logs say now?




```
+ grep -q ' on /media/da1 '
+ [ YES = NO ]
+ __wait_for_device /dev/da1
+ local COUNT=0
+ head -c 1 /dev/da1
+ file -b -L -s /dev/da1
+ sed -E 's/label:\ \".*\"//g'
+ __create_mount_point /dev/da1
+ mkdir -p /media/da1
+ [ 0 != 0 ]
+ __wait_for_device /dev/da1
+ local COUNT=0
+ head -c 1 /dev/da1
+ which ntfs-3g
+ __wait_for_device /dev/da1
+ local COUNT=0
+ head -c 1 /dev/da1
+ ntfs-3g /dev/da1 /media/da1
Error opening '/dev/da1': Operation not permitted
Failed to mount '/dev/da1': Operation not permitted
The NTFS partition is hibernated. Please resume and shutdown Windows
properly, or mount the volume read-only with the 'ro' mount option, or
mount the volume read-write with the 'remove_hiberfile' mount option.
For example type on the command line:

            mount -t ntfs-3g -o remove_hiberfile /dev/da1 /media/da1

+ __log '/dev/da1: mount failed (ntfs) '\''ntfs-3g  /dev/da1 /media/da1'\'
+ date '+%Y-%m-%d %H:%M:%S'
+ echo 2013-03-07 02:24:36 '/dev/da1: mount failed (ntfs) '\''ntfs-3g  /dev/da1 /media/da1'\'
+ exit 1
```


----------



## vermaden (Mar 7, 2013)

Niatross said:
			
		

> ```
> + ntfs-3g /dev/da1 /media/da1
> Error opening '/dev/da1': Operation not permitted
> Failed to mount '/dev/da1': Operation not permitted
> ...



I have added -o remove_hiberfile option to NTFS-3G mount, check the latest version from GITHUB:

```
https://raw.github.com/vermaden/automount/master/automount
```

*Fastest fix:*

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

If it still does not work, send me automount logs


----------



## Niatross (Mar 7, 2013)

> I have added -o remove_hiberfile option to NTFS-3G mount



That didn't help.

It looks like "automount" (and/or "ntfs-3g") is not creating "/dev/fuse0".


----------



## vermaden (Mar 7, 2013)

Niatross said:
			
		

> That didn't help.
> 
> It looks like "automount" (and/or "ntfs-3g") is not creating "/dev/fuse0".



Any logs on that topic?

There is no possible way for automount to create /dev/fuse0, its not something that automount can do. After loading fuse.ko the /dev/fuse0 should be creted, have You tried to reuild fusefs-kmod package with portmaster?


----------



## Niatross (Mar 7, 2013)

> Any logs on that topic?



Logs are attached...



> After loading fuse.ko, the /dev/fuse0 should be created.



Well, the /dev/fuse0 is not getting created. The kldstat utility confirms fuse.ko is loaded, but the /dev/fuse0 is not getting created.



> Have You tried to rebuild fusefs-kmod package with portmaster?



No I haven't.


----------



## vermaden (Mar 7, 2013)

Niatross said:
			
		

> Logs are attached...


Thanks.



			
				Niatross said:
			
		

> Well, the /dev/fuse0 is not getting created. The kldstat utility confirms fuse.ko is loaded, but the /dev/fuse0 is not getting created.



This seems to be 'known' problem, not related to automount: 
http://forums.freebsd.org/showthread.php?t=15961


----------



## Niatross (Mar 20, 2013)

vermaden,

Automount won't mount a FAT32 partition on my USB flash disk. The automount.log file displays the following error:


```
/dev/da1: mount failed (fat) 'mount_msdosfs -o large -o longnames -D cp437 -L en_US.ISO8859-1 -m 644 -M 755 /dev/da1 /media/da1
```

It looks similar to the NTFS bug that was fixed (above).


----------



## vermaden (Mar 20, 2013)

Please provide output of the `file -s /dev/da1` command.

Can you mount that drive manually from the command line?

If yes, then what mount command works for you?

About the /var/log/automount.log file, I need the WHOLE file (not only single line).


----------



## Niatross (Mar 20, 2013)

Here are the details:

The FAT32 flash disk was formatted using a Windows 7 operating system. The flash disk is 8GB in size and contains a 8GB FAT32 partition on it.

I have tried to use automount to mount the FAT32 partition, but it will not mount during boot.

The FAT32 partition mounts perfectly fine using the following command: `mount_msdosfs /dev/da1 /media/da1`

I have the following line in my /etc/rc.conf file:


```
fusefs_enable="YES"
```

I have the following lines in my /boot/loader.conf file:


```
libiconv_load=YES
cd9660_iconv_load=YES
msdosfs_iconv_load=YES
ntfs_iconv_load=YES
udf_iconv_load=YES
```

PS: I've even tried 
	
	



```
fuse_load=YES
```
 in the file (above).

The `kldstat` command displays the following:


```
Id Refs Address            Size     Name
 1   48 0xffffffff80200000 11cdab0  kernel
 2    1 0xffffffff813ce000 8900     vesa.ko
 3    1 0xffffffff813d7000 1190     ntfs_iconv.ko
 4    2 0xffffffff813d9000 efe8     ntfs.ko
 5    5 0xffffffff813e8000 6f40     libiconv.ko
 6    3 0xffffffff813ef000 45058    linux.ko
 7    1 0xffffffff81435000 4bb8     vmxnet.ko
 8    1 0xffffffff8143a000 9aa8     vmxnet3.ko
 9    1 0xffffffff81444000 11c8     cd9660_iconv.ko
10    1 0xffffffff81446000 11d8     msdosfs_iconv.ko
11    1 0xffffffff81448000 1178     udf_iconv.ko
12    2 0xffffffff8144a000 9b18     udf.ko
13    1 0xffffffff81612000 1582     fdescfs.ko
14    1 0xffffffff81614000 429d     linprocfs.ko
15    1 0xffffffff81619000 a058     fuse.ko
16    1 0xffffffff81624000 1e7      linux_adobe.ko
17    1 0xffffffff81625000 1464     vmmemctl.ko
18    1 0xffffffff81627000 2d50     vmblock.ko
```

The `file -s /dev/da1` command displays the following:


```
/dev/da1: x86 boot sector, code offset 0x58, OEM-ID "MSDOS5.0", sectors/cluster 8, reserved sectors 2270, Media descriptor 0xf8, heads 255, sectors 15646720 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 15249, reserved3 0x800000, serial number 0x2a6aee05, unlabeled
```

The DEBUG.da.attach.log file displays the following error:


```
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
+ [ da1 = --version ]
+ [ da1 = -h -o da1 = --help -o 2 -eq 0 -o 2 -eq 1 ]
+ [ -f /usr/local/etc/automount.conf ]
+ . /usr/local/etc/automount.conf
+ : /media
+ : /var/log/automount.log
+ : /var/run/automount.state
+ : en_US.ISO8859-1
+ : cp437
+ : %Y-%m-%d %H:%M:%S
+ : NO
+ : YES
+ : NO
+ : 0
+ : 0
+ : 8
+ : 0.3
+ [ NO = YES ]
+ DEV=/dev/da1
+ __log '/dev/da1: attach'
+ date '+%Y-%m-%d %H:%M:%S'
+ echo 2013-03-19 17:41:23 '/dev/da1: attach'
+ [ '' != '' ]
+ ADD=0
+ MNT=/media/da1
+ __check_already_mounted -d /dev/da1
+ mount
+ local 'MOUNT=/dev/da0s1a on / (ufs, local)
devfs on /dev (devfs, local, multilabel)
/dev/da0s1d on /tmp (ufs, local, soft-updates)
/dev/da0s1f on /usr (ufs, local, soft-updates)
/dev/da0s1e on /var (ufs, local, soft-updates)
procfs on /proc (procfs, local)
fdescfs on /dev/fd (fdescfs)
linprocfs on /usr/compat/linux/proc (linprocfs, local)'
+ echo '/dev/da0s1a on / (ufs, local)
devfs on /dev (devfs, local, multilabel)
/dev/da0s1d on /tmp (ufs, local, soft-updates)
/dev/da0s1f on /usr (ufs, local, soft-updates)
/dev/da0s1e on /var (ufs, local, soft-updates)
procfs on /proc (procfs, local)
fdescfs on /dev/fd (fdescfs)
linprocfs on /usr/compat/linux/proc (linprocfs, local)'
+ grep -q '^/dev/da1 on '
+ __check_already_mounted -m /media/da1
+ mount
+ local 'MOUNT=/dev/da0s1a on / (ufs, local)
devfs on /dev (devfs, local, multilabel)
/dev/da0s1d on /tmp (ufs, local, soft-updates)
/dev/da0s1f on /usr (ufs, local, soft-updates)
/dev/da0s1e on /var (ufs, local, soft-updates)
procfs on /proc (procfs, local)
fdescfs on /dev/fd (fdescfs)
linprocfs on /usr/compat/linux/proc (linprocfs, local)'
+ echo '/dev/da0s1a on / (ufs, local)
devfs on /dev (devfs, local, multilabel)
/dev/da0s1d on /tmp (ufs, local, soft-updates)
/dev/da0s1f on /usr (ufs, local, soft-updates)
/dev/da0s1e on /var (ufs, local, soft-updates)
procfs on /proc (procfs, local)
fdescfs on /dev/fd (fdescfs)
linprocfs on /usr/compat/linux/proc (linprocfs, local)'
+ grep -q ' on /media/da1 '
+ [ YES = NO ]
+ __wait_for_device /dev/da1
+ local COUNT=0
+ head -c 1 /dev/da1
+ file -b -L -s /dev/da1
+ sed -E 's/label:\ \".*\"//g'
+ __create_mount_point /dev/da1
+ mkdir -p /media/da1
+ [ 0 != 0 ]
+ __wait_for_device /dev/da1
+ local COUNT=0
+ head -c 1 /dev/da1
+ fsck_msdosfs -y /dev/da1
+ read LINE
+ __log '/dev/da1: fsck_msdosfs ** /dev/da1'
+ date '+%Y-%m-%d %H:%M:%S'
+ echo 2013-03-19 17:41:24 '/dev/da1: fsck_msdosfs ** /dev/da1'
+ read LINE
+ __log '/dev/da1: fsck_msdosfs ** Phase 1 - Read and Compare FATs'
+ date '+%Y-%m-%d %H:%M:%S'
+ echo 2013-03-19 17:41:24 '/dev/da1: fsck_msdosfs ** Phase 1 - Read and Compare FATs'
+ read LINE
+ __log '/dev/da1: fsck_msdosfs ** Phase 2 - Check Cluster Chains'
+ date '+%Y-%m-%d %H:%M:%S'
+ echo 2013-03-19 17:41:24 '/dev/da1: fsck_msdosfs ** Phase 2 - Check Cluster Chains'
+ read LINE
+ __log '/dev/da1: fsck_msdosfs ** Phase 3 - Checking Directories'
+ date '+%Y-%m-%d %H:%M:%S'
+ echo 2013-03-19 17:41:24 '/dev/da1: fsck_msdosfs ** Phase 3 - Checking Directories'
+ read LINE
+ __log '/dev/da1: fsck_msdosfs ** Phase 4 - Checking for Lost Files'
+ date '+%Y-%m-%d %H:%M:%S'
+ echo 2013-03-19 17:41:24 '/dev/da1: fsck_msdosfs ** Phase 4 - Checking for Lost Files'
+ read LINE
+ __log '/dev/da1: fsck_msdosfs 63 files, 3611852 free (1951539 clusters)'
+ date '+%Y-%m-%d %H:%M:%S'
+ echo 2013-03-19 17:41:24 '/dev/da1: fsck_msdosfs 63 files, 3611852 free (1951539 clusters)'
+ read LINE
+ __wait_for_device /dev/da1
+ local COUNT=0
+ head -c 1 /dev/da1
+ mount_msdosfs -o large -o longnames -m 644 -M 755 -D cp437 -L en_US.ISO8859-1 /dev/da1 /media/da1
mount_msdosfs: Unable to load iconv library: Shared object "libiconv.so" not found, required by "mount_msdosfs"
: No such file or directory
mount_msdosfs: msdosfs_iconv: No such file or directory
+ __log '/dev/da1: mount failed (fat) '\''mount_msdosfs  -o large -o longnames -D cp437 -L en_US.ISO8859-1 -m 644 -M 755 /dev/da1 /media/da1'\'
+ date '+%Y-%m-%d %H:%M:%S'
+ echo 2013-03-19 17:41:24 '/dev/da1: mount failed (fat) '\''mount_msdosfs  -o large -o longnames -D cp437 -L en_US.ISO8859-1 -m 644 -M 755 /dev/da1 /media/da1'\'
+ exit 1
```

Note:
This procedure has been tried on brand new FreeBSD 9.0-RELEASE and FreeBSD 9.1-RELEASE operating systems with the same results. The FAT32 partition will not mount during boot. It will mount just fine using the "mount_msdosfs" command. 

IMPORTANT:
Please use the exact same procedures (above) and format an 8GB partition (on a 8GB flash drive)  with FAT32 using a Windows 7 operating system and tell me how you can possibly automount it during boot. Use FreeBSD 9.0-RELEASE or FreeBSD 9.1-RELEASE. Do not use STABLE or any other FreeBSD version when you try this experiment and get back with me on your results. Something is amiss with automount.

I'll tell you something else. Automount will not mount a NTFS partition during boot (using NTFS-3G) if "Subversion" is installed. Weird but true. Once you uninstall "Subversion", automount will mount NTFS partitions during boot (using NTFS-3G) with no issues whatsoever.  Another thing: NTFS partitions can be mounted by hand (using the "ntfs-3g" executable) with or without "Subversion" installed. Don't know what's going on here, but automount has issues mounting partitions during the boot process. REMEMBER: I'm using automount on brand new operating systems.


----------



## vermaden (Mar 20, 2013)

Install converters/libiconv and try again.

Type this command on the command line and tell me if it works:
# mount_msdosfs -o large -o longnames -m 644 -M 755 -D cp437 -L en_US.ISO8859-1 /dev/da1 /media/da1


----------



## Niatross (Mar 20, 2013)

vermaden said:
			
		

> Install converters/libiconv and try again.



converters/libiconv is already installed. When I try to re-install converters/libiconv, I receive the following error:


```
libiconv-1.14_1 is already installed
```

I did a "make deinstall" and a "make install clean" to reinstall it.



> Type this command on the command line and tell me if it works:
> # mount_msdosfs -o large -o longnames -m 644 -M 755 -D cp437 -L en_US.ISO8859-1 /dev/da1 /media/da1



I typed the command (above) and it mounts just fine.

What is automount colliding with (when its trying to mount a file system during boot)? How come I can mount manually, but automount won't mount a file system during boot? If I boot the system and then pull the flash drive out and plug it back in, automount will mount the file system with no problems. BTW: Are you testing automount with virtual machines (ex: "VMware")?


----------



## larkind (Apr 2, 2013)

@vermaden

Thanks for your efforts, I find it good and easy to use.

But I found little problem with mounting flash cards with partitions, as the script seems to ignore device slices:

```
2013-04-02 16:36:19 /dev/da1: attach
2013-04-02 16:36:20 /dev/da1: filesystem not supported or no filesystem
```
As I found, default automount_devd.conf just checks for the main device, indeed:

```
match "cdev" "(da|mmcsd)[0-9]+";
```
After replacing it with:

```
match "cdev" "(da|mmcsd)[0-9].*";
```
all seem to work now:

```
2013-04-02 16:36:19 /dev/da1: attach
2013-04-02 16:36:20 /dev/da1: filesystem not supported or no filesystem
2013-04-02 16:36:20 /dev/da1s1: attach
2013-04-02 16:36:21 /dev/da1s1: mount (exfat)
```
Is it Ok to change?


----------



## vermaden (Apr 3, 2013)

Niatross said:
			
		

> What is automount colliding with (when its trying to mount a file system during boot)? How come I can mount manually, but automount won't mount a file system during boot? If I boot the system and then pull the flash drive out and plug it back in, automount will mount the file system with no problems.


I implemented BOOTDELAY option (defaults to 45 seconds) to wait for boot process to complete and then mount the devices, check version from GITHUB: https://raw.github.com/vermaden/automount/master/automount



			
				Niatross said:
			
		

> BTW: Are you testing automount with virtual machines (ex: "VMware")?


Nope. Any issues with them?



			
				larkind said:
			
		

> @vermaden
> 
> Thanks for your efforts, I find it good and easy to use.


Welcome.



			
				larkind said:
			
		

> But I found little problem with mounting flash cards with partitions, as the script seems to ignore device slices:
> 
> ```
> 2013-04-02 16:36:19 /dev/da1: attach
> ...


Yes. I also made that change 'upstream' (but with little difference "(da|mmcsd)[0-9]+.*" so da10could be used), so it wont be necessary in the future, if @Niatross will confirm that fix for boot is working, then I would start the 1.4.4 release process.


----------



## T-Aoki (Apr 4, 2013)

vermaden said:
			
		

> Yes. I also made that change 'upstream' (but with little difference "(da|mmcsd)[0-9]+.*" so da10could be used), so it wont be necessary in the future, if @Niatross will confirm that fix for boot is working, then I would start the 1.4.4 release process.



Thanks, @larkind and @vermaden!
I manually applied above fix (@vermaden's version) to my /usr/local/etc/devd/automount_devd.conf,
restart devd and then automount successfully mounts partitioned
MicroSD card and USB memstick.
But not tested with multi partitioned, multi filesystem medium. (Tested USB memstick is one created with FreeBSD-9.0-BETA3-i386-memstick.img, GPT partitioned and one of two partition is dedicated for gptboot, so having only one valid filesystem. All others are single partitioned)

Note that I'm using most recent version in ports tree.


----------



## arachnid (Aug 6, 2014)

In 10-STABLE the `file` command was changed. Now the output is:


```
# file -b -L -s /dev/da0s1                                                  
DOS/MBR boot sector
```
In FreeBSD 9:

```
# file -b -L -s /dev/da0s1
x86 boot sector, code offset 0x0, OEM-ID "        ", sectors/cluster 64, reserved sectors 1294, Media descriptor 0xf8, heads 255, hidden sectors 8192, sectors 61822976 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 7545, reserved3 0x800000, serial number 0x90164ef8, unlabeled
```

Therefore under 10-STABLE `automount` writes to the log file:

```
2014-08-06 14:58:55 /dev/da0s1: attach
2014-08-06 14:58:55 /dev/da0s1: filesystem not supported or no filesystem
```


----------



## vermaden (Aug 6, 2014)

arachnid said:
			
		

> In 10-STABLE the `file` command was changed.



This is output from 10-STABLE from 2014/06/10:

```
% file -b -L -s /dev/da0    
x86 boot sector; partition 1: ID=0xc, active, starthead 1, startsector 63, 15117102 sectors, code offset 0x31

% file -b -L -s /dev/da0s1
x86 boot sector, code offset 0x58, OEM-ID "BSD4.4  ", sectors/cluster 64, heads 255, sectors 15117102 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 1845, Backup boot sector 2, serial number 0xbe1d1b16, label: "STEEL      "

% uname -a
FreeBSD w530.domain.com 10.0-STABLE FreeBSD 10.0-STABLE #0 r267321: Tue Jun 10 13:53:21 CEST 2014     root@w530.domain.com:/usr/obj/usr/src/sys/GENERIC  amd64
```

Was that more recent change?


----------



## SirDice (Aug 6, 2014)

It's probably due to an update to file/libmagic. Which happened on 24 June, a few days after your 10-STABLE build. 

http://svnweb.freebsd.org/base?view=rev ... ion=267843


----------



## vermaden (Aug 6, 2014)

SirDice said:
			
		

> It's probably due to an update to file/libmagic. Which happened on 24 June, a few days after your 10-STABLE build.
> 
> http://svnweb.freebsd.org/base?view=rev ... ion=267843


Thanks, downloading latest STABLE ISO as we speak. Will add follow up here and/or update the sysutils/automount.


----------



## arachnid (Aug 6, 2014)

Yes, my version  
	
	



```
10.0-STABLE FreeBSD 10.0-STABLE #3 r269298: Wed Jul 30 13:55:43 MSK 2014
```


----------



## vermaden (Aug 7, 2014)

arachnid said:
			
		

> In 10-STABLE the `file` command was changed.



Fixed, required adding *-k* flag to *file(1)*.
https://github.com/vermaden/automount/c ... b3c58706bd


----------



## arachnid (Aug 7, 2014)

vermaden said:
			
		

> arachnid said:
> 
> 
> 
> ...



Big thanks!


----------



## vermaden (Aug 7, 2014)

arachnid said:
			
		

> vermaden said:
> 
> 
> 
> ...


Welcome.

For the record, the *-k* flag does not break *automount* on pre-commit FreeBSD version with older file(1).


----------



## free-and-bsd (Aug 8, 2014)

Yea, thanks from me, too, @vermaden  :beergrin  :beergrin . Updated to STABLE some time ago and just somehow only now noticed that auto mounting stopped working  :q . But adding the '-k' fixed it. Why, life is always interesting!


----------



## sk8harddiefast (Nov 11, 2014)

Hi vermaden I have a little problem with automount and I need your help*. *I installed it and I added the -k flag into the /usr/local/sbin/automount script. Also in my /etc/rc.conf file *I* added these lines:

```
devd_enable="YES"
fusefs_enable="YES"
```

In my /usr/local/etc/automount.conf I have this:

```
USERUMOUNT=YES
ATIME=YES
POPUP=YES
REMOVEDIRS=YES
FM="thunar"
USER=ember
ENCODING=pl_PL.ISO8859-2
CODEPAGE=cp852
MNTPREFIX=/media
```

My problem is that when I insert a USB, it doesn't mount automatically. I must run `ember@FreeBSD / $ /usr/local/sbin/automount da0s1 attach` to mount it on /media. It also returns me this:

```
/usr/local/sbin/automount: cannot create /var/log/automount.log: Permission denied
/usr/local/sbin/automount: cannot create /var/log/automount.log: Permission denied
/usr/local/sbin/automount: cannot create /var/log/automount.log: Permission denied
```

What did I miss?

I am running 
	
	



```
FreeBSD FreeBSD 10.1-RC4 FreeBSD 10.1-RC4 #0 r273874: Fri Oct 31 08:49:44 UTC 2014  root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
```


----------



## vermaden (Nov 11, 2014)

sk8harddiefast said:


> Hi vermaden I have a little problem with automount and I need your help*. *I installed it and I add *-k* flag into /usr/local/sbin/automount script.



Tha latest automount is always here:
https://github.com/vermaden/automount/



sk8harddiefast said:


> My problem is that when I instert a usb it doesn't mount automatically.



Show me your /usr/local/etc/devd/automount_devd.conf file.



sk8harddiefast said:


> I must run:
> `ember@FreeBSD / $ /usr/local/sbin/automount da0s1 attach`
> to be mounted on /media
> Also return me this:
> ...


The automount, when run by devd is run as '*root*', user '*ember*' does not have WRITE access to /var/log/automount.log file.


----------



## sk8harddiefast (Nov 11, 2014)

So remove 
	
	



```
devd_enable="YES"
```
 from /etc/rc.conf?

My /usr/local/etc/devd/automount_devd.conf file


```
notify 100 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/usr/local/sbin/automount $cdev attach";
};

notify 100 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+";
  action "/usr/local/sbin/automount $cdev detach";
};
```


----------



## vermaden (Nov 12, 2014)

sk8harddiefast said:


> So remove
> 
> 
> 
> ...



The devd(8) daemon is enabled by default:

```
% grep devd /etc/defaults/rc.conf
devd_enable="YES"  # Run devd, to trigger programs on device tree changes.
```



sk8harddiefast said:


> My /usr/local/etc/devd/automount_devd.conf file
> 
> 
> ```
> ...



Ok, the old one (worked because devd had a 'bug' 

Put this into that file:

```
notify 100 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev attach";
};

notify 100 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev detach";
};
```

The difference is:

```
-  match "cdev" "(da|mmcsd)[0-9]+";
+  match "cdev" "(da|mmcsd)[0-9]+.*";
```

... and to be even more precise, this '.*' is missing at the end.


----------



## sk8harddiefast (Nov 12, 2014)

Worked perfect! My question is: Why the automount is on ports and not included into FreeBSD? Is just amazing. Uses devd, don't need X server to work and don't need any configuration to work. Is small, flexible and all this make it a wonderful solution!


----------



## vermaden (Nov 13, 2014)

sk8harddiefast said:


> Worked perfect! My question is: Why the automount is on ports and not included into FreeBSD? Is just amazing. Uses devd, don't need X server to work and don't need any configuration to work. Is small, flexible and all this make it a wonderful solution!


Ask FreeBSD Developers the same question, you know where the FreeBSD mailing lists are 

... and thanks by the way.


----------



## jdakhayman (Nov 16, 2014)

Hello,

I've been using automount 1.4.3 successfully for quite some time on FreeBSD 10.0-RELEASE, FreeBSD 9.3-RELEASE, and FreeBSD 9.2-RELEASE.

When FreeBSD 10.1-RELEASE was released this past week, I installed it on a second hard drive, and set[]up my standard desktop environment with Xfce to do some testing.

I installed automount using ports. I did not compile it with support for any of the special filesystems listed in the configuration options. I only use FAT (MSDOSFS) and UFS.

I made the appropriate changes to the  /usr/local/etc/devd/automount_devd.conf file as shown in the thread above:


```
notify 100 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev attach";
};

notify 100 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev detach";
};
```
I also have modified the /usr/local/etc/automount.config file as follows:

```
USERUMOUNT=YES
ATIME=NO
REMOVEDIRS=YES
FM="thunar"
USER=jda
ENCODING="en_US.ISO8859-1"
CODEPAGE="cp437"
```
I use this same configuration on my FreeBSD 10.0-RELEASE machine as well.

Using a USB memory stick that is formatted using the following commands (This works with my FreeBSD 10.0-RELEASE install with out any issue):

`gpart destroy -F /dev/da0`
`gpart create -s mbr /dev/da0`
`gpart add -t \!12 /dev/da0`
`newfs_msdosfs -F32 /dev/da0s1`

Gives me the following in the log file located in /var/log/automount.log when I insert the USB memory stick on my FreeBSD 10.1-RELEASE machine.


```
2014-11-16 15:31:22 /dev/da0: attach
2014-11-16 15:31:22 /dev/da0: filesystem not supported or no filesystem
2014-11-16 15:31:22 /dev/da0s1: attach
2014-11-16 15:31:22 /dev/da0s1: filesystem not supported or no filesystem
```
Any guesses as to what I may be doing wrong here?


----------



## vermaden (Nov 17, 2014)

jdakhayman said:


> I installed automount using ports. I did not compile it with support for any of the special filesystems listed in the configuration options. I only use FAT (MSDOSFS) and UFS.


Generally, the FreeBSD developers gave me very 'simple' choice: You have the automount package without exfat support or automount with exfat but without package.



jdakhayman said:


> Any guesses as to what I may be doing wrong here?


The distinction between FAT32 and NTFS is generally the hardest part of automount, sometimes it fails, because its not that simple.

Submit please the first 1024KB of this device, I will try do debug it.

But also try to use the latest automount version from here: https://github.com/vermaden/automount/


----------



## uzsolt (Nov 18, 2014)

sk8harddiefast said:


> My question is: Why the automount is on ports and not included into FreeBSD?


Check autofs(5)! It's usable in 10.1.


----------



## vermaden (Nov 18, 2014)

uzsolt said:


> Check autofs()! It's usable in 10.1.


How to use/configure it to have a USB pendrive automounting like with sysutils/automount?


----------



## zwieblum (Nov 18, 2014)

If I understand it right, then auto_master(5) is the configuration file, it comes even with some examples. So it looks not very different from your solution, but might be a bit more difficult to configure.


----------



## uzsolt (Nov 18, 2014)

vermaden said:


> How to use/configure it to have USB pendrive automounting like with *sysutils/automount*?


I didn't upgrade 10.0 to 10.1 yet, so I don't know details, sorry.


----------



## wblock@ (Nov 18, 2014)

trasz@ is working on updating the man pages and adding more examples.  While I have not tried it yet, it looks more to me like amd(8), where a device is mounted when the user tries to access it.  Might not be too hard to use devd(8) to detect new devices and mount them on detection.


----------



## jdakhayman (Nov 19, 2014)

jdakhayman said:


> Hello,
> 
> I've been using automount 1.4.3 successfully for quite some time on FreeBSD 10.0-RELEASE, FreeBSD 9.3-RELEASE, and FreeBSD 9.2-RELEASE.
> 
> ...



I was looking at this again today, and I noticed that the new autofs and associated utilities, that is now included with FreeBSD 10.1-RELEASE, has a system binary in /usr/sbin/ that is named automount. Does this by chance conflict with the script named automount that's installed by /usr/ports/sysutil/automount located in usr/local/sbin/?


----------



## vermaden (Nov 20, 2014)

jdakhayman said:


> I was looking at this again today, and I noticed that the new autofs and associated utilities, that is now included with FreeBSD 10.1-RELEASE, has a system binary in /usr/sbin/ that is named automount. Does this by chance conflict with the script named automount that's installed by /usr/ports/sysutil/automount located in usr/local/sbin/?


Nope, no conflict.

The devd(8) uses full PATH for 'mine' automount.

On the other hand, while there are now two 'automounts' in the PATH You will execute (by hand from terminal) the one that is first in PATH, but that does not break the sysutils/automount proper work.


----------



## vg (Dec 13, 2014)

After up-dating to 10.1 automount doesn't work.
log:

```
2014-12-13 23:14:26 /dev/da0: random wait for '2,0' seconds before 'attach' action
2014-12-13 23:14:26 /dev/da0: attach
2014-12-13 23:14:27 /dev/da0: filesystem not supported or no filesystem
2014-12-13 23:14:27 /dev/da0s1: random wait for '1,0' seconds before 'attach' action
2014-12-13 23:14:27 /dev/da0s1: attach
2014-12-13 23:14:28 /dev/da0s1: filesystem not supported or no filesystem
2014-12-13 23:14:28 /dev/da1: random wait for '1,0' seconds before 'attach' action
2014-12-13 23:14:28 /dev/da1: attach
2014-12-13 23:14:28 /dev/da1: filesystem not supported or no filesystem
```
automount_devd.conf

```
notify 100 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev attach";
};

notify 100 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev detach";
};
```
automount.conf

```
USERUMOUNT=YES
ATIME=NO
REMOVEDIRS=YES
FM="xfe"
USER=vg
MNTPREFIX="/mnt/vg"
ENCODING="ru_RU.UTF-8"
CODEPAGE="cp866"
```


----------



## uzsolt (Dec 13, 2014)

Can you mount da0s1? The
	
	



```
2014-12-13 23:14:28 /dev/da0s1: filesystem not supported or no filesystem
```
message is very strange.


----------



## vg (Dec 13, 2014)

uzsolt said:


> Can you mount da0s1? ...


Yes. Both da0s1, and da1 are manually mounted without problems.


----------



## free-and-bsd (Dec 16, 2014)

vg said:


> Yes. Both da0s1, and da1 are manually mounted without problems.


Have you carefully checked this post?


----------



## densan (Dec 23, 2014)

KRE4, dolpin and automount work

```
FM="kioclient exec "
```


----------



## protocelt (Jan 2, 2015)

vermaden, I appreciate you taking the time to create and offer a port for this. I've been using it for some time and it's been working great. Dziękuję!

I noticed on the GitHub page you linked to in one of your posts, you have a tarball for a version 1.5(?) vs version 1.43 in the ports tree. Did you have any plans on updating the port in the near future? It is working fine for me as is, but was only curious.


----------



## vermaden (Jan 7, 2015)

protocelt said:


> vermaden, I appreciate you taking the time to create and offer a port for this. I've been using it for some time and it's been working great. Dziękuję!



Welcome. 



protocelt said:


> I noticed on the GitHub page you linked to in one of your posts, you have a tarball for a version 1.5(?) vs version 1.43 in the ports tree. Did you have any plans on updating the port in the near future? It is working fine for me as is, but was only curious.


I asked one of the FreeBSD Developers to update the port but no luck.


----------



## zwieblum (Jan 21, 2015)

To make your program work on 10.1 I had to add `-k` to Line 287 (v1.5). That is, I had to change 

```
case $( file -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' ) in
```
 to 

```
case $( file -k -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' ) in
```

Now it works like a charm


----------



## jdakhayman (Jan 22, 2015)

zwieblum said:


> To make your program work on 10.1 I had to add `-k` to Line 287 (v1.5). That is, I had to change
> 
> ```
> case $( file -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' ) in
> ...



I just did this as well, and it's working great for me, too. I was really missing using this on 10.1, and couldn't figure it out.Thanks for the tip!

jda


----------



## Crivens (Jan 22, 2015)

I have one quick question, and maybe a feature idea. How about a ZPOOL on a stick? I find most USB devices to be pretty slow when used with the more traditional file systems but pretty fast when using larger blocks on them. That might speed things up a bit, but I do not want to run FAT with 128KB clusters...


----------



## vermaden (Jan 23, 2015)

Crivens said:


> I have one quick question, and maybe a feature idea. How about a ZPOOL on a stick? I find most USB devices to be pretty slow when used with the more traditional file systems but pretty fast when using larger blocks on them. That might speed things up a bit, but I do not want to run FAT with 128KB clusters...


Last time I checked* file(1)* is not able to tell if there is ZFS pool on the device or not.


----------



## free-and-bsd (Jan 31, 2015)

But it doesn't have to be file(1)? `zpool --import` could be run after the detection of a new storage device. Then, with the output being "0", the script would continue as it does without any ZFS awareness, otherwise switch to ZFS related commands.

Then, for example, if the mountpoints of the newly detected zpool are already used in the running system, some options may be presented, etc. Which is, of course, a whole new chapter .


----------



## protocelt (Feb 1, 2015)

While ZFS would be a nice feature, unless I'm mistaken, you would have to remember to manually export the pool each time before unplugging the device anyway which kind of negates the usefulness IMO.


----------



## vermaden (Feb 2, 2015)

The *automount* has been updated to 1.5.2, the 'filesystem detection' has been reworked mostly:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197023

I will look into the ZFS detection and automatic mount/umount.


----------



## vermaden (Feb 2, 2015)

_"I will look into the ZFS detection and automatic mount/umount."_

The zpool export -f POOL command is not possible to be executed when the device has been ejected, so its not possible to implement ZFS into sysutils/automount port.


----------



## Crivens (Feb 3, 2015)

Since it is generally a bad idea to unmount a file system after its storage has been removed (wrong order), I don't see the difference as such. Simply removing the media is likely to screw up any file system involved, sometimes terminally. Is the problem in fact that  zpool export -f POOL  will not remove the hanging filesystem? In that case, this is bad luck indeed.


----------



## protocelt (Feb 3, 2015)

Crivens said:


> Is the problem in fact that  zpool export -f POOL  will not remove the hanging filesystem? In that case, this is bad luck indeed.


It's been some time now but doing this caused a hard panic and rebooted my system last time I unwittingly did this. It don't know if this is still the case today. I was using 10-STABLE at the time so it could of course just have been my setup.


----------



## free-and-bsd (Feb 3, 2015)

Yea, bad habit removing USB drive without unmounting it. I know some people who believe "this isn't necessary anymore", what with the striking progress of the MS Win OS . I say, such people mustn't be let anywhere close to a ZFS file system or FreeBSD for that matter.


----------



## vermaden (Feb 3, 2015)

Crivens said:


> Since it is generally a bad idea to unmount a file system after its storage has been removed (wrong order), I don't see the difference as such.


Then having several ZOMBIE processes trying to export ZFS pool forever is not a problem for You? For me its a BUG.



Crivens said:


> Simply removing the media is likely to screw up any file system involved, sometimes terminally.


Not true. For most time You only need to run fsck to mark filesystem as clean after removal before unmounting. After many removals of mounted filesystems with automount I have never ended with screwed filesystem.


----------



## Crivens (Feb 4, 2015)

Well, I have been at scientific conferences where the presentation was handed out on paper because the highly trained scientists pulled out their USB sticks without proper unmounting them and found out the files were shredded just before the talk. So it was back to good old "Open your books (proceedings) at page ...". I carry such items on at least three different types of data carrier, for that reason.

Any my question was aimed at the behaviour of the programms. Having ZOMBIE processes doing something is not good, it is a bug. But the same would/should be the case with other file systems. There, the forced unmount cleans up such things (I hope). The proper order is always to first unmount a file system and THEN remove the storage media.


----------



## vermaden (Feb 4, 2015)

Crivens said:


> Well, I have been at scientific conferences where the presentation was handed out on paper because the highly trained scientists pulled out their USB sticks without proper unmounting them and found out the files were shredded just before the talk. So it was back to good old "Open your books (proceedings) at page ...". I carry such items on at least three different types of data carrier, for that reason.


I definitely do not encourage to remove pendrive without unmounting at all times, I also did not said that all files copied to the ungracefully removed pendrive will be there, I just said that it never trashed my filesystem, fsck was always able to fix it and mark it clean. For most of the times files were there, several times last copied files were missing.



Crivens said:


> Any my question was aimed at the behaviour of the programms. Having ZOMBIE processes doing something is not good, it is a bug. But the same would/should be the case with other file systems. There, the forced unmount cleans up such things (I hope). The proper order is always to first unmount a file system and THEN remove the storage media.


ZFS datasets are not mounted, but pool is still imported:


```
% zpool list
NAME  SIZE  ALLOC  FREE  EXPANDSZ  FRAG  CAP  DEDUP  HEALTH  ALTROOT
local  216G  190G  25.6G  -  -  88%  1.00x  ONLINE  -
sys  15.9G  6.25G  9.62G  -  -  39%  1.00x  ONLINE  -
test  7.19G  69.5K  7.19G  -  0%  0%  1.00x  UNAVAIL  -
```

I tried to export it with force after pendrive removal, but that only creates zombie processes, they are probably harmless, I still got them as I do suspend/resume most of the time:

```
% ps ax|grep export
24782  6- I+  0:00.00 sudo zpool export -f test
24783  6- D+  0:00.00 zpool export -f test
16911  7- D+  0:00.01 zpool export -f test
73716 12  S+  0:00.00 grep --color export
36120  8- IN  0:00.00 sudo zpool export -f test
36121  8- DN  0:00.00 zpool export -f test
```


----------



## Crivens (Feb 4, 2015)

Under the evidence brought up I do need to change my point of view - supporting ZFS would be more trouble than it will be worth. Sad, but true.


----------



## vermaden (Feb 4, 2015)

Crivens said:


> Under the evidence brought up I do need to change my point of view - supporting ZFS would be more trouble than it will be worth. Sad, but true.


Its not that hard, if only that BUG that prevents from exporting ZFS pool after the pendrive is removed, its not that hard.

I already had 'flow' in my mind, but that BUG stopped all work


----------



## Crivens (Feb 5, 2015)

That was what annoyed me a bit. Allowing ZFS should not be hard, unless I do not understand all things involved (can happen, but would be a bit embarrasing) OR there is some hidden problem that should not be there in the first place. And that is what happened. I did not know that exporting the pool after the device is gone would lead to deadlocks, zombies or even kernel panics. That should not happen, and I am confident that these things will be fixed. After that, it may be possible to have ZFS in the automount.


----------



## vermaden (Feb 5, 2015)

Crivens said:


> That was what annoyed me a bit. Allowing ZFS should not be hard, unless I do not understand all things involved (can happen, but would be a bit embarrasing) OR there is some hidden problem that should not be there in the first place. And that is what happened. I did not know that exporting the pool after the device is gone would lead to deadlocks, zombies or even kernel panics. That should not happen, and I am confident that these things will be fixed. After that, it may be possible to have ZFS in the automount.


There was time in FreeBSD history when removing the pendrive with any mounted filesystem would end in kernel panic. Thanks to *@trasz *this is not longer a problem


----------



## zspider (Feb 5, 2015)

vermaden said:


> There was time in FreeBSD history when removing the pendrive with any mounted filesystem would end in kernel panic. Thanks to *@trasz *this is not longer a problem



Yep, I'm salty enough to remember those days, "why is this thing freezing all the time? " Lol.


----------



## Crivens (Feb 6, 2015)

I remember them, too. 

But then, we were happy that this newfangled thing called USB was working at all.


----------



## vermaden (Feb 6, 2015)

vermaden said:


> Its not that hard, if only that BUG that prevents from exporting ZFS pool after the pendrive is removed, its not that hard.
> 
> I already had 'flow' in my mind, but that BUG stopped all work


BUG reported:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197364


----------



## vermaden (Feb 6, 2015)

The *automount 1.5.3* has been imported into FreeBSD Ports tree:
https://svnweb.freebsd.org/ports?view=revision&revision=378537


----------



## nadstaky (Feb 6, 2015)

Hello,

I'm using 1.5.3 on FreeBSD 10.1.

Now it mounts NTFS external hard disk, but not with its label (Iomega), but with its /dev/ name. And once mounted, I cannot unmount.

Please help!

Thanks,

Nad


----------



## nadstaky (Feb 7, 2015)

Ok, I've tried every version. Only FAT32 stuffs mount.
For NTFS it never works, I find this strange as it works for you all...

Please help :/


----------



## hukadan (Feb 7, 2015)

Hi,

If you want help, you need to give us some information. First post automount_devd.conf and  automount.conf.

Then, give us the result of `pkg info | grep fuse`. And check you have 
	
	



```
fusefs_enable=YES
```
 in etc/rc.conf.


----------



## vermaden (Feb 7, 2015)

nadstaky said:


> Hello,
> 
> I'm using 1.5.3 on FreeBSD 10.1.
> 
> ...


NTFS is pretty 'random', its not about automount, its about the ntfs-3g. For example I have found many NTFS drives that will mount but I would not be able to write files on it (but can read), or it does not mount at all. 

If You can, omit NTFS, its not safe filesystem.


----------



## nadstaky (Feb 7, 2015)

Thanks,

Well I do have fusefs_enable="YES" in /etc/rc.conf

Here is the result of `pkg info | grep fuse`:

```
# pkg info | grep fuse
fusefs-exfat-1.0.1  Full-featured exFAT FS implementation as a FUSE module
fusefs-ext4fuse-0.1.3,1  EXT4 implementation for FUSE
fusefs-libs-2.9.3_3  FUSE allows filesystem implementation in userspace
fusefs-ntfs-2014.2.15_2  Mount NTFS partitions (read/write) and disk images
```
Here is automount.conf:

```
USERUMOUNT=YES
ATIME=NO
POPUP=YES
REMOVEDIRS=NO
FM="thunar"
USER=bioman
ENCODING=fr_FR.ISO8859-2
CODEPAGE=cp852
MNTPREFIX=/media
```
And automount_devd.conf:

```
notify 100 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev attach";
};

notify 100 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev detach";
};
```
Is there a way to fix name of the device (currently /dev/foo), was the device label before.

vermaden: I cannot use another fs then NTFS, because I need my external HDD at work (Windows world), plus it works fine under Archlinux


----------



## vermaden (Feb 7, 2015)

nadstaky said:


> Is there a way to fix name of the device (currently /dev/foo), was the device label before.


The sysutils/automount only checks for /dev/da* and /dev/mmcsd* devices:

```
% cat /usr/local/etc/devd/automount_devd.conf
notify 100 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev attach";
};

notify 100 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev detach";
};
```
You may of course change that so it will also check labels on /dev.


nadstaky said:


> vermaden: I cannot use another fs then NTFS, because I need my external HDD at work (Windows world), plus it works fine under Archlinux


FAT32 or exFAT will work the same here.


----------



## nadstaky (Feb 8, 2015)

Thanks vermaden, it does not solve my problem.

Could you tell me what to change to get the device label name instead of the /dev/foo?

Also, does your scripts require HAL ?

Thanks,
Nad


----------



## nadstaky (Feb 8, 2015)

Well, it NEEDS HAL. Under Xfce4, now no devices are mounted anymore


----------



## vermaden (Feb 8, 2015)

nadstaky said:


> Thanks vermaden, it does not solve my problem.
> 
> Could you tell me what to change to get the device label name instead of the /dev/foo?



I do not use labels, where are labels located?





nadstaky said:


> Also, does your scripts require HAL ?





nadstaky said:


> Well, it NEEDS HAL. Under Xfce4, now no devices are mounted anymore



Whats wrong with You people? 

It *DOES NOT REQUIRE HAL*, it does not use HAL at all even if HAL is installed. The only thing it really requires is *DEVD*, that is why its *devd(8) *based *automount*


----------



## nadstaky (Feb 8, 2015)

Okay, so my FreeBSD is f*cked up ^^
With version 1.4.3, my USB key was mounted in /media/TOSHIBA.  But 1.4.3 does not work with 10.1 IIRC.


----------



## vermaden (Feb 9, 2015)

nadstaky said:


> Okay, so my FreeBSD is f*cked up ^^
> With version 1.4.3, my USB key was mounted in /media/TOSHIBA.  But 1.4.3 does not work with 10.1 IIRC.


FreeBSD 10.x came with newer file(1) that needs -k flag now.

The other thing is that the config in port for devd(8) was working with older devd(8) while newer devd(8) has fixed regular expressions so needed a newer config, check this whole thread for details.


----------



## ykirill (Feb 28, 2015)

Hi vermaden,
I installed your program from ports automount-1.5.3 and I have problems with automount in mounting USB flash drives with msdos file systems. The problem is all drives I have don't have 'DOS/MBR' string. Here are some examples:

```
1. x86 boot sector, code offset 0x58, OEM-ID "BSD4.4  ", sectors/cluster 64, heads 255, sectors 7904295 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 965, Backup boot sector 2, serial number 0xd76016f9,  DOS executable (COM), boot code
2. x86 boot sector, code offset 0x58, OEM-ID "MSDOS5.0", sectors/cluster 8, reserved sectors 38, Media descriptor 0xf8, heads 255, hidden sectors 2976, sectors 7904352 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 7705, serial number 0x1938c1c6, unlabeled DOS executable (COM), boot code
3. x86 boot sector, Microsoft Windows 98 Bootloader IO.SYS+MSDOS.SYS, code offset 0x3c, OEM-ID "MSWIN4.1", sectors/cluster 32, root entries 512, Media descriptor 0xf8, sectors/FAT 245, heads 255, hidden sectors 63, sectors 2006976 (volumes > 32 MB) , serial number 0x66b10487, unlabeled, FAT (16 bit) DOS executable (COM), boot code
```
Instead of 'DOS/MBR' I have 'x86'. Removing 'DOS/MBR' on line 298 fixed my problem.

```
if echo "${TYPE}" | grep -q 'ext4'
  then
  TYPE=EXT4
  return
  fi
-   if echo "${TYPE}" | grep -q 'DOS/MBR boot sector'
+  if echo "${TYPE}" | grep -q 'boot sector'
  then
  __log "${TYPE} boot"

  TYPE=$( file -r -k -b -L -s ${DEV} | sed -E 's/label:\ \".*\"//g' )
  if echo "${TYPE}" | grep -q 'Unix Fast File'
  then
  TYPE=UFS
  return
  fi
```


----------



## vermaden (Feb 28, 2015)

ykirill

Changed.

New 1.5.4 version is available on GitHub.

You may create PR to here to update the port:
https://bugs.freebsd.org/bugzilla/enter_bug.cgi


----------



## Crivens (Mar 30, 2015)

I have two things I would like to share/suggest.

One thing that got me was the hard coded user name in the config file. I had to set up a labtop (no spelling mistake, a laptop for lab work) which is used by more than one user. Since each user has his own preferences, there can not be one standard user for that machine. But now this static configuration line does not work. So I replaced that one with this line:

```
USER=`ls -l /tmp/Xrootenv|cut -w -f 3`
```
This is giving me the currently running X user. This is most likely not elegant, but it works well for now. Maybe this can be a suggestion for improvements. Also, this only works with X running, but if you are running in console mode, you may also know how to use the rectangular assortment of rectangular things in front of you to spell the magic invocation needed to mount a file system. 

The second point is that I have tried to use PEFS with removable media. It would be a good add-on if the automounter would, after mounting, check for a hint on the device and then use the correct key file to mount the content with PEFS, in some sensible way. When using some indication for the key file on the device, you can have the key in some user directory, and maybe have several keys there for several projects. That way you may encrypt the data for different use cases with different keys, without looking them up each time or handing _one_ keyfile around to world+dog for 'convenience'.

Thank you for reading.


----------



## vermaden (Mar 30, 2015)

Crivens

Thanks for input.



Crivens said:


> I have two things I would like to share/suggest.
> 
> One thing that got me was the hard coded user name in the config file. I had to set up a labtop (no spelling mistake, a laptop for lab work) which is used by more than one user. Since each user has his own preferences, there can not be one standard user for that machine. But now this static configuration line does not work. So I replaced that one with this line:
> 
> ...



I do not have /tmp/Xrootenv file on my machine, what generates it?

As for checking the user which runs X11, this seems to be able to check who started the X11 server:


```
% pgrep X | tail -1
1180

% ps -o ppid -p 1180 | tail -1
1179

% ps -o user -p 1179 | tail -1
vermaden
```



Crivens said:


> The second point is that I have tried to use PEFS with removable media. It would be a good add-on if the automounter would, after mounting, check for a hint on the device and then use the correct key file to mount the content with PEFS, in some sensible way.


Any proposition how to find out which key to use for which media?


----------



## Crivens (Mar 30, 2015)

vermaden said:


> Crivens
> 
> Thanks for input.
> 
> ...



Your method resolves to PID 1 on my system. I am using  xdm, running from /etc/ttys. Maybe that one sets up the Xrootenv?
It seems this is not so easy  Any idea how to do this, without using some daemon or *kit? maybe /usr/bin/last might be a way to find out who is active on :0. That may work.

How to check for the keys might simply be a text file holding the name of the key which may then be located in $USER/.pefs_keys/$contents_of_that_file.key. Would that work?

I think encryption, expecially of removable media, is really important and some easy way to do so is needed. Whenever I can not find one of the pendrives I use I start to worry what may be on that thing and if it may be a problem if that data is showing up where it does not belong. And I guess I am not alone with that.


----------



## vermaden (Mar 31, 2015)

Crivens said:


> Your method resolves to PID 1 on my system. I am using  xdm, running from /etc/ttys. Maybe that one sets up the Xrootenv?
> It seems this is not so easy  Any idea how to do this, without using some daemon or *kit? maybe /usr/bin/last might be a way to find out who is active on :0. That may work.



So now we have detected X11 'owner' for *xdm* and 'manual start', now we will have to add checks for *lxdm*, *pcdm*, *kdm*, *gdm*, .... its not the right way I think.

I will introduce other option, GROUP option as an addon to USER option, this way *automount *can set g+w bit with group on the mount point, so a user that is in that group will be able to write there.



Crivens said:


> How to check for the keys might simply be a text file holding the name of the key which may then be located in $USER/.pefs_keys/$contents_of_that_file.key. Would that work?



So we can introduce an option for PEFS key files, what about GELI ... or GDBE ... or other forms of encryption? IMHO currently encryption is out of scope for *automount*, create some simple scripts for yourself with start/stop option for this drive (and possibly others) and job done.



Crivens said:


> I think encryption, expecially of removable media, is really important and some easy way to do so is needed. Whenever I can not find one of the pendrives I use I start to worry what may be on that thing and if it may be a problem if that data is showing up where it does not belong. And I guess I am not alone with that.


I definitely agree and I use GELI on devices that I whink need encryption, but such a drive is useless on other operating systems, Mac OS X, Windows or even Linux does not support GELI ...


----------



## Crivens (Mar 31, 2015)

It was a quick attempt to adapt the settings, but I know the way to determinate the correct X user is not fool proof. Maybe the `last` way is better, it would also keep file manager working for the user, would it?

I really think I need to spend time with the start/stop parts of devd myself, so I can get the crypto working.

And thank you all for your time to read and respond.


----------



## digital-freak (Jun 5, 2015)

Hi all!
I have two system with FreeBSD 10.1. And a flesh drive with the NTFS.
One of them is:

```
$ uname -v
FreeBSD 10.1-STABLE #1 r275939: Sat Dec 20 14:15:25 YEKT 2014  cyrax@mobi.digital-freak.home:/usr/obj/usr/src/sys/MOBI  i386
```
And installed sysutils/automount 1.5.3 and sysutils/fusefs-ntfs 2015.3.14.
All disks with NTFS works perfect.
Also:

```
$ file -k -b -L -s /dev/da0s1 | sed -E 's/label:\ \".*\"//g'
DOS/MBR boot sector, code offset 0x52+2, OEM-ID "NTFS  ", sectors/cluster 8, Media
descriptor 0xf8, sectors/track 63, heads 255, hidden sectors 63, dos < 4.0 BootSector
(0x0); NTFS, sectors/track 63, physical drive 0x80, sectors 15663311, $MFT start cluster
786432, $MFTMirror start cluster 2, bytes/RecordSegment 2^(-1*246), clusters/index block 1,
serial number 02eaa77e7aa77a9cb; contains Microsoft Windows XP/VISTA bootloader
BOOTMGR
```

Second is:

```
$ uname -pv
FreeBSD 10.1-STABLE #1 r281993: Sun Apr 26 14:53:21 YEKT 2015  root@cyrax.digital-freak.home:/usr/obj/usr/src/sys/CYRAX  amd64
```
sysutils/automount 1.5.3 and sysutils/fusefs-ntfs 2015.3.14 are installed. But disks with NTFS is not mounted.
I tried these:

```
# /usr/local/sbin/automount da0s1 attach
printf: .30000000000000000000: expected numeric value
usage: sleep seconds
mount_msdosfs: /dev/da0s1: Invalid argument
```
And `file` shows me:

```
$ file -k -b -L -s /dev/da0s1 | sed -E 's/label:\ \".*\"//g'
DOS/MBR boot sector, code offset 0x52+2, OEM-ID "NTFS  ", sectors/cluster 8, Media
descriptor 0xf8, sectors/track 63, heads 255, hidden sectors 63, dos < 4.0 BootSector
(0x0), FAT (1Y bit by descriptor); NTFS, sectors/track 63, physical drive 0x80, sectors
15663311, $MFT start cluster 786432, $MFTMirror start cluster 2, bytes/RecordSegment
2^(-1*246), clusters/index block 1, serial number 02eaa77e7aa77a9cb; contains Microsoft
Windows XP/VISTA bootloader BOOTMGR\012- DOS/MBR boot sector DOS/MBR boot
sector dBase IV DBT of  .DBF, block length 63488, next free block index 1318081259, next
free block 1677812736, next used block 1677943810
```


----------



## vermaden (Jun 6, 2015)

Fixed.

Try now.


----------



## digital-freak (Jun 6, 2015)

vermaden said:


> Fixed.
> 
> Try now.




```
$ /usr/local/sbin/automount --version
automount 1.5.5 2015/06/06
```
It is correct?

Not work. I paste `__fstype()` function to another file and added printing values of `${TYPE}` variable:

```
$ ./test da0s1
FAT

$ gpart show -p da0
=>  63  15667137  da0  MBR  (7.5G)
  63  15663312  da0s1  ntfs  [active]  (7.5G)
  15663375  3825  - free -  (1.9M)
```

I tried these small changes of `__fstype()` function:

```
--- test.orig   2015-06-06 14:40:46.061868000 +0500
+++ test   2015-06-06 14:41:06.749376000 +0500
@@ -39,14 +39,14 @@
  TYPE=UFS
  return
  fi
-  if echo "${TYPE}" | grep -q 'FAT'
+  if echo "${TYPE}" | grep -q 'NTFS'
  then
-  TYPE=FAT
+  TYPE=NTFS
  return
  fi
-  if echo "${TYPE}" | grep -q 'NTFS'
+  if echo "${TYPE}" | grep -q 'FAT'
  then
-  TYPE=NTFS
+  TYPE=FAT
  return
  fi
  fi
```
and it is works for me.

```
$ ./test da0s1
NTFS
```


----------



## vermaden (Jun 8, 2015)

Merged.

Thanks.


----------



## abishai (Jun 28, 2015)

I have a memory stick with Xubuntu (ext4). When I try to mount it, it mounts, but USER option is ignored. I searched the thread, but found no similar problems.

```
2015-06-28 10:52:46 /dev/da0: random wait for '0.3' seconds before 'attach' action
2015-06-28 10:52:46 /dev/da0: attach
2015-06-28 10:52:46 /dev/da0: filesystem not supported or no filesystem
2015-06-28 10:52:47 /dev/da0s1: random wait for '1.4' seconds before 'attach' action
2015-06-28 10:52:47 /dev/da0s1: attach
2015-06-28 10:52:47 /dev/da0s1: fsck.ext4 /dev/da0s1: clean, 190669/3858432 files, 1181850/15424896 blocks
2015-06-28 10:52:47 /dev/da0s1: mount (ext4)
```


```
root@darkstar:~ # ls -lAF /media
total 4
dr-xr-xr-x  22 root  wheel  4096 27 Jun 23:53 da0s1/
```


```
root@darkstar:~ # chown abishai:wheel /media/da0s1/
chown: /media/da0s1/: Function not implemented
```
Is it really not implemented or I miss something ?


----------



## Crivens (Jun 28, 2015)

Ext4 is mounted, if I remember correctly, using a fuse driver. It may be possible that "chown" is not part of that implementation.


----------



## abishai (Jun 28, 2015)

As I suspected... I reformatted to ext3.


----------



## andersbo87 (Jul 19, 2015)

Having seen that automount works well for external drives, how can I get it to work on my *internal* ones as well?
Can I use automount for that at all, or do I have to stick to /etc/fstab?
Can I just do something like this in /usr/local/etc/devd/automount_devd.conf:

```
notify 100 {
  match "system" "DEVFS";
  match "type" "CREATE";   
  match "cdev" "(ada|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev attach";
};

notify 100 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(ada|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev detach";
};
```
Where "ada" is my internal drive?



vermaden said:


> I do not use labels, where are labels located?


Suppose you have a msdosfs formatted partition. Also suppose that when you formatted that partition you gave it the name "MYDRIVE".
If that partition exists on an internal drive or if you connect an external drive that contains that partition, a directory named "msdosfs" appears in the /dev/ directory. If you take a look inside that /dev/msdosfs/ directory you should get the following output:

```
[CMD]$ ls /dev/msdosfs[/CMD]
MYDRIVE
```

The same thing goes for drives that are formatted with NTFS.
When I take a look inside the /dev/ntfs folder on my own computer (as you can see, I have labeled 3 NTFS partitions), I get the following output:

```
[CMD]ls /dev/ntfs/[/CMD]
Acer       Data      RECOVERY
```

All of those 3 partitions are on 2 internal disks. To me, using labels makes it easier to mount partitions when needed, as I don't have to remember which device node I have to type when I want to mount a partition. A couple of examples: 
Instead of having to type `mount_ntfs-3g /dev/ada1p4 /mnt`, I can type `mount_ntfs-3g /dev/ntfs/Data /mnt`. Instead of writing `mount_ntfs-3g /dev/ada0p4 /mnt` I can write `mount_ntfs-3g /dev/ntfs/Acer /mnt`.


----------



## vermaden (Jul 20, 2015)

andersbo87 said:


> Having seen that automount works well for external drives, how can I get it to work on my *internal* ones as well?
> Can I use automount for that at all, or do I have to stick to /etc/fstab?
> Can I just do something like this in /usr/local/etc/devd/automount_devd.conf:
> 
> ...



Just add 'ada' to the existing 'da|mmcsd' set so it will become 'da|mmcsd|ada' set:


```
notify 100 {
  match "system" "DEVFS";
  match "type" "CREATE"; 
  match "cdev" "(da|mmcsd|ada)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev attach";
};

notify 100 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd|ada)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev detach";
};
```



andersbo87 said:


> Suppose you have a msdosfs formatted partition. Also suppose that when you formatted that partition you gave it the name "MYDRIVE".
> If that partition exists on an internal drive or if you connect an external drive that contains that partition, a directory named "msdosfs" appears in the /dev/ directory. If you take a look inside that /dev/msdosfs/ directory you should get the following output:
> 
> ```
> ...



I agree that mounting based on labels would be far better... but not all filesystems have labels... the automount will have to check for labels and then to check which labels are on which drives/partitions and then mount some existing labels and non existing drives/partition after the labelled ones have been mounted... or first mount new label and then mount all other newly detected drives/partitions hoping that they would fail to mount one over another because its already mounted 

I have other idea in my mind... to create symlink with label in /media, so if something was mounted as /media/da0s1 and it has label 'DATA' then a symlink would be created as /media/DATA -> /media/da0s1... but I will have to add tracking of adding and removing links... and take care of overlapping labels, first time it would be 'DATA' the second one would probably be 'DATA72345' ('DATA${RANDOM}')... will have to think about it 

...also if there is no label then serial number + partition can be used


----------



## andersbo87 (Jul 28, 2015)

I tried the automount script on my NTFS partitions. It turned out I had to make a couple of changes for the script to work:
I had to change the line

```
if echo "${TYPE} | grep -q 'FAT'"
```
to

```
if echo "${TYPE} | grep -q 'FAT (32 bit)'"
```
This was because my NTFS partitions seemed to be identified as FAT partitions. At least, messages from `dmesg -a` kept on saying that fsck_msdosfs could not check that partition for errors. Changing "FAT" to "FAT (32 bit)" in the if statment above seemed to fix that problem.
I think that what caused my NTFS partition to be identified as an FAT partition was the following (correct me if I am wrong): "FAT (1Y bit by descriptor)"
The following "code" is the output of `dmesg -a` when the automount script mounts one of my NTFS partitions:

```
DOS/MBR boot sector, code offset 0x52+2, OEM-ID "NTFS  ", sectors/cluster 8, Media descriptor 0xf8, sectors/track 63, heads 255, hidden sectors 1807747072, dos < 4.0 BootSector (0x80), FAT (1Y bit by descriptor); NTFS, sectors/track 63, sectors 2099281919, $MFT start cluster 786432, $MFTMirror start cluster 2, bytes/RecordSegment 2^(-1*246), clusters/index block 1, serial number 03e34075634071117
```
That "broke" the possibility of automounting my USB drive which was an msdosfs formatted drive.
To work around that, I added yet another change:

```
if echo "${TYPE}" | grep -q 'MSDOS'
  then
  TYPE=FAT
  return
  fi
```
So therefore I propose the following code:

```
if echo "${TYPE}" | grep -q 'MSDOS'
  then
  TYPE=FAT
  return
  fi
  if echo "${TYPE}" | grep -q 'FAT (32 bit)'
  then
   TYPE=FAT
   return
  fi
  if echo "${TYPE}" | grep -q 'NTFS'
  then
  TYPE=NTFS
  return
  fi
```
Also beware that when using NTFS-3G, mount might fail because NTFS-3G thinks that the NTFS partitions is in an unsafe state.
As a tips, if you don't want/need RW access to those partitions, you can add "-o ro" to the command that mounts the NTFS volume:

```
if which ntfs-3g 1> /dev/null 2> /dev/null # sysutils/fusefs-ntfs
then
  __wait_for_device ${DEV}
  if ntfs-3g -o recover -o remove_hiberfile -o ro ${OPTS} ${DEV} ${MNT}
  then
    ADD=1
  else
    # make nested mount try because sometimes second mount works
    if ntfs-3g -o recover -o remove_hiberfile -o ro ${OPTS} ${DEV} ${MNT}
    then
      ADD=1
    else
      __log "${DEV}: mount failed (ntfs) 'ntfs-3g ${OPTS} ${DEV} ${MNT}'"
    exit 1
  fi
fi
```


----------



## vermaden (Jul 28, 2015)

andersbo87 said:


> (...)
> 
> So therefore I propose the following code:
> 
> ...



Close ...

You are referring to 1.5.3 which is in Ports, 1.5.4 from GITHUB already has that switched, but I merged Your ideas anyway just in case so latest 1.5.5 looks like that:


```
if echo "${TYPE}" | grep -q 'NTFS'
  then
    TYPE=NTFS
    return
  fi
  if echo "${TYPE}" | grep -q 'MSDOS'
  then
    TYPE=FAT
    return
  fi
  if echo "${TYPE}" | grep -q 'FAT (32 bit)'
  then
    TYPE=FAT
    return
  fi
  if echo "${TYPE}" | grep -q 'FAT'
  then
    TYPE=FAT
    return
  fi
```


----------



## vermaden (Jul 28, 2015)

Added request for 1.5.5 update ...
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=201943


----------



## junovitch@ (Aug 2, 2015)

vermaden said:


> Added request for 1.5.5 update ...
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=201943



Updated to 1.5.7.  Thanks vermaden.


----------



## vermaden (Aug 2, 2015)

junovitch@ said:


> Updated to 1.5.7.  Thanks vermaden.


Thanks for updating the port.


----------



## Windmill (May 6, 2016)

Is this the default automount that comes with FreeBSD 10.3? So I don't need to install it from ports?


----------



## pkubaj (May 6, 2016)

Windmill said:


> Is this the default automount that comes with FreeBSD 10.3? So I don't need to install it from ports?


No, FreeBSD uses its own automounter that you can use, or install the one by vermaden from ports.


----------



## Windmill (May 6, 2016)

Oh ok, which is better to use?


----------



## pkubaj (May 6, 2016)

Windmill said:


> Oh ok, which is better to use?


None is better. Both have their own pros and cons.


----------



## fernandel (Jul 3, 2016)

Hi!

I am using automount with partial success. Mounting usb and firewire external drive with ufs and fat partitions works great but automount for CD/DVD doesn't work and I don't have any error message.

```
automount.conf
USERUMOUNT=YES
ATIME=NO
REMOVEDIRS=YES
# FM="nautilus --browser --no-desktop"
USER=fernandel
ENCODING=en_US.UTF-8
CODEPAGE=cp437
```

And automount_devd.conf:

```
notify 100 {
  match "system" "DEVFS";
  match "type" "CREATE";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev attach";
};

notify 100 {
  match "system" "DEVFS";
  match "type" "DESTROY";
  match "cdev" "(da|mmcsd)[0-9]+.*";
  action "/usr/local/sbin/automount $cdev detach";
};
```


```
pkg info |grep fuse
fusefs-exfat-1.0.1  Full-featured exFAT FS implementation as a FUSE module
fusefs-ext4fuse-0.1.3,1  EXT4 implementation for FUSE
fusefs-libs-2.9.5  FUSE allows filesystem implementation in userspace
fusefs-ntfs-2016.2.22_1  Mount NTFS partitions (read/write) and disk images
```

Thank you.


----------



## vermaden (Jul 7, 2016)

CD/DVD in FreeBSD does not do any DEVD events so automount is not able to mount them.


----------



## vermaden (Jun 13, 2018)

Just updated 𝗮𝘂𝘁𝗼𝗺𝗼𝘂𝗻𝘁 to 1.5.8.
https://github.com/vermaden/automount/tree/1.5.8
𝗖𝗵𝗮𝗻𝗴𝗲𝘀:
- Omit GVFS in 𝚖𝚘𝚞𝚗𝚝(𝟾) listing.
- Improve default exFAT mount options.
- Add 𝚖𝚘𝚞𝚗𝚝_𝚖𝚜𝚍𝚘𝚜𝚏𝚜(𝟾) fallback.
- Set caja as file manager in example.
- Add version option.


----------



## priyadarshan (Jun 13, 2018)

vermaden said:


> Just updated 𝗮𝘂𝘁𝗼𝗺𝗼𝘂𝗻𝘁 to 1.5.8.



Thank you for `automount`. I always admired your coding.


----------



## Crivens (Jun 13, 2018)

Could there be a problem with encoding in this posting? In the reply, I see it is automount. In the original, there is a string of boxes.
And also from me a thank-you for automount.


----------



## vermaden (Jun 13, 2018)

@ Crivens

Welcome.
I used UTF8 chars for Twitter as Twitter does not support any formatting like bold/italic and as I pasted that message here there may be some problems with encoding, sorry for that.


----------



## Crivens (Jun 13, 2018)

No problem. Just mentioning it so a reason can be found. Twitter sounds a good source of this confusion.


----------



## vermaden (Dec 8, 2018)

New 𝚊𝚞𝚝𝚘𝚖𝚘𝚞𝚗𝚝 version *1.5.9* now supports XFS/HFS/MTP (Android phones for example) filesystems and have various other fixes. Its not in the FreeBSD Ports yet. It also requires *x11/zenity* for MTP.

Here is the CHANGELOG:

Decrease DELAY for sleep from '1' to '0.1' for faster mounting.
Remove __random_wait() at 'attach'.
Implement MTP mounting.
Added XFS and HFS support.
Various fixes and cleanups.
Grab it directly from usual place: https://github.com/vermaden/automount

Also new 𝗨𝗣𝗗𝗔𝗧𝗘 𝟮 - 𝗧𝗵𝗲 𝚜𝚢𝚜𝚞𝚝𝚒𝚕𝚜/𝚊𝚞𝚝𝚘𝚖𝚘𝚞𝚗𝚝 𝟭.𝟱.𝟵 𝗨𝗽𝗱𝗮𝘁𝗲 addon to the 𝗙𝗿𝗲𝗲𝗕𝗦𝗗 𝗗𝗲𝘀𝗸𝘁𝗼𝗽 - 𝗣𝗮𝗿𝘁 𝟭𝟳 - 𝗔𝘂𝘁𝗼𝗺𝗼𝘂𝗻𝘁 𝗥𝗲𝗺𝗼𝘃𝗮𝗯𝗹𝗲 𝗠𝗲𝗱𝗶𝗮 article is available.

https://vermaden.wordpress.com/2018/10/11/freebsd-desktop-part-17-automount-removable-media/

Regards.


----------



## twllnbrck (Dec 9, 2018)

vermaden - great work! Hope it'll go to Ports soon. I'm using automount and beadm on my desktop PC and it works like charm. Just wanted to say thank you!


----------



## vermaden (Dec 9, 2018)

Lanakus said:


> vermaden - great work! Hope it'll go to Ports soon. I'm using automount and beadm on my desktop PC and it works like charm. Just wanted to say thank you!



Thanks 

I already asked Bryan to update the port, he usually needs less then a week for that.


----------



## vermaden (Dec 9, 2018)

Small 𝚊𝚞𝚝𝚘𝚖𝚘𝚞𝚗𝚝 fix with 1.6.0 version.

*| CHANGELOG
| *Fix long boot with devd(8) because of ugen(4) devices.

Not yet in FreeBSD Ports or packages.

Grab it directly from usual place:
https://github.com/vermaden/automount


----------



## arachnid (Dec 14, 2018)

after upgrade from 11.2 to 12.0-RELEASE  automount don't work.
cause - mount_msdosfs don't understand options 'large', although in man this options is present.

sorry, i don't view last version in git - everything should work there. but i use version from port tree.


----------



## vermaden (Dec 15, 2018)

arachnid said:


> after upgrade from 11.2 to 12.0-RELEASE  automount don't work.
> cause - mount_msdosfs don't understand options 'large', although in man this options is present.
> 
> sorry, i don't view last version in git - everything should work there. but i use version from port tree.



Bryan did not yet updated the sysutils/automount port.

This is the fix for version installed from FreeBSD Ports/packages:

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


----------



## twllnbrck (Jan 31, 2019)

Hi vermaden,

is there any progress with updating sysutils/automount port? According to FreshPorts.org the version is still 1.5.8.
Im actually using 1.6.0 from github source and I noticed some that you have made 1.6.1 update recently.
Everything is still working so Im just asking for interest.

Best regards to Poland


----------



## vermaden (Feb 1, 2019)

Its not up to me unfortunately :/


----------



## free-and-bsd (Feb 15, 2019)

Yes, the automount facility that's part of the OS now still offers no way to allow for regular user write/unmount of the automounted media. Which kind of reduces its usability, doesn't it? For more often than not people use removable USB drives in order to _write_ something there.

Thank you, vermaden, very much for YOUR hard work on this very useful script .

Just today a friend visited me and asked to write a couple of files on a USB flash drive. He's not very friendly with computer stuff in general, but among the things he does know is that you insert a USB drive and then you use it, period. So I couldn't explain it to him nor to myself why it is that the most advanced OS (which I sincerely believe FreeBSD to be) can't offer an official way to do the same thing. So I will leave the automount(8) to developers to fiddle with until it comes to maturity and in the meantime will use this very helpful script of yours.


----------



## fernandel (Feb 16, 2019)

vermaden said:


> Its not up to me unfortunately :/


Do you know what should be the reason for so long waiting time, please?


----------



## vermaden (Feb 18, 2019)

free-and-bsd said:


> Yes, the automount facility that's part of the OS now still offers no way to allow for regular user write/unmount of the automounted media. Which kind of reduces its usability, doesn't it? For more often than not people use removable USB drives in order to _write_ something there.
> 
> Thank you, vermaden, very much for YOUR hard work on this very useful script .
> 
> Just today a friend visited me and asked to write a couple of files on a USB flash drive. He's not very friendly with computer stuff in general, but among the things he does know is that you insert a USB drive and then you use it, period. So I couldn't explain it to him nor to myself why it is that the most advanced OS (which I sincerely believe FreeBSD to be) can't offer an official way to do the same thing. So I will leave the automount(8) to developers to fiddle with until it comes to maturity and in the meantime will use this very helpful script of yours.



Welcome, happy automounting (and autounmounting) I wish You


----------



## vermaden (Dec 3, 2019)

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


----------

