From owner-freebsd-questions@FreeBSD.ORG Thu Aug 28 05:19:11 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B6691065674 for ; Thu, 28 Aug 2008 05:19:11 +0000 (UTC) (envelope-from on@cs.ait.ac.th) Received: from mail.cs.ait.ac.th (mail.cs.ait.ac.th [192.41.170.16]) by mx1.freebsd.org (Postfix) with ESMTP id A8A9A8FC14 for ; Thu, 28 Aug 2008 05:19:10 +0000 (UTC) (envelope-from on@cs.ait.ac.th) Received: from banyan.cs.ait.ac.th (banyan.cs.ait.ac.th [192.41.170.5]) by mail.cs.ait.ac.th (8.13.1/8.13.1) with ESMTP id m7S4fpH3049996 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 28 Aug 2008 11:41:51 +0700 (ICT) (envelope-from on@banyan.cs.ait.ac.th) Received: (from on@localhost) by banyan.cs.ait.ac.th (8.14.2/8.12.11) id m7S4fp7O015836; Thu, 28 Aug 2008 11:41:51 +0700 (ICT) Date: Thu, 28 Aug 2008 11:41:51 +0700 (ICT) Message-Id: <200808280441.m7S4fp7O015836@banyan.cs.ait.ac.th> From: Olivier Nicole To: freebsd-questions@freebsd.org X-Virus-Scanned: on CSIM by amavisd-milter (http://www.amavis.org/) Subject: How to use automount daemon (amd) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Aug 2008 05:19:11 -0000 Hi, 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/amd.map: /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/amd.map 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/amd.map /host toplvl 1 localhost is up /etc/amd.map /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 disk. 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 127.0.0.1 which works but with the error: rpcbind: cannot bind 127.0.0.1 on udp: Address already in use Is there a way to start rpcbind on localhost only? Best regards, Olivier