How to use automount daemon (amd)

Olivier Nicole on at
Thu Aug 28 05:19:11 UTC 2008


I have the following issue with amd.

I want to write a script that will detect whenever a USB disk is
plugged in and then run a backup.

My configuration is described below.

File /etc/

/defaults        type:=host;fs:=${autodir}/${rhost};rhost:=${key}
*               opts:=rw,grpid,resvport,nfsv2

localhost       type:=auto;fs:=${map};pref:=${key}/

localhost/da0   type:=program;fs:=/automnt/da0;\
                mount:="/usr/local/sbin/fsck_mount fsck_mount /automnt/da0";\
                unmount:="/usr/local/sbin/spin_down spin_down /automnt/da0"

where fsck_mount is a short script that does a fsck_ffs -p, to catch
unclean file system) then a mount and spin_down a script that does
umount then camcrontrol stop.

file /etc/fstab:

/dev/da0s1d             /automnt/da0    ufs     rw,noauto       0       0

And amd runs with the parameters:

/usr/sbin/amd -p -a /.amd_mnt -l syslog /host /etc/

When I play with mounting and dismounting the USB disk by hand, it
works fine:

- I attach the USB disk, wait for usbd to detect umass and create the
  disk da0

- I access to /host/localhost/da0

- I launch my backup by hand.

- I amq -u /host/localhost/da0 to umount the disk da0

- I remove the USB drive.

All this is OK.

But I would like my backup script to be able to check whether the USB
disk is present or not.

If I try to access /host/localhost/da0 while the USB disk is not
attached, I get no error (ls /host/localhost/da0 returns empty).

Then I attach the USB disk and wait for it to start. Then try to ls
again but it still gives me nothing. Mount will not show that
/automnt/da0 is mounted.

It seems that if I try to access /host/localhost/da0 when there is no
corresponding disk, amd remembers that error and refuse to mount the
disk later until the cache is cleared.

The command amq -m shows:
"root"                   amanda:(pid1290)  root     1   localhost is up
/etc/             /host             toplvl   1   localhost is up
/etc/             /host/localhost   auto     1   localhost is up
fsck_mount /automnt/da0  /automnt/da0      program  1   localhost is up

where /automnt/da0 seems to be mounted even when there is no such

I think that if my backup script tries to check /host/localhost/da0
with a period (every 10 minutes) greater than amd cache timeout
(default 5 minutes), then it should be able to detect when the disk is
mounted the next time.

I could reduce the cache time out too, but that may interfeer with the
efficiency of amd.

I wonder if there is a different way to check that the disk is
available, than trying to ls /host/localhost/da0.

A side question about rpcbind.

I'd like to start rpcbind to bind only to localhost. I tried:

/usr/sbin/rpcbind -h

which works but with the error:

rpcbind: cannot bind on udp: Address already in use

Is there a way to start rpcbind on localhost only?

Best regards,


More information about the freebsd-questions mailing list