From owner-freebsd-questions@FreeBSD.ORG Thu Mar 10 01:40:28 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AA1FE16A4CE for ; Thu, 10 Mar 2005 01:40:28 +0000 (GMT) Received: from mail.gmx.net (pop.gmx.net [213.165.64.20]) by mx1.FreeBSD.org (Postfix) with SMTP id A0A4943D5D for ; Thu, 10 Mar 2005 01:40:27 +0000 (GMT) (envelope-from m@MHoerich.de) Received: (qmail invoked by alias); 10 Mar 2005 01:40:25 -0000 Received: from pD9E58B6D.dip.t-dialin.net (EHLO localhost) (217.229.139.109) by mail.gmx.net (mp006) with SMTP; 10 Mar 2005 02:40:25 +0100 X-Authenticated: #5114400 Date: Thu, 10 Mar 2005 02:40:22 +0100 From: Mario Hoerich To: Duane Winner Message-ID: <20050310014017.GC8033@Pandora.MHoerich.de> References: <422F4DB5.1040900@att.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <422F4DB5.1040900@att.net> User-Agent: Mutt/1.4.2.1i X-Y-GMX-Trusted: 0 cc: freebsd-questions@FreeBSD.org Subject: Re: auto mount external hard drive but only when present? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Mar 2005 01:40:28 -0000 # Duane Winner: > I have a laptop with a docking station and in the expansion bay of the > dock, I have a second hard drive, which I have configured as /dev/ad4s1d > and mount it to /hd2 [...] > But because this is a laptop, and will be pulled off the dock when I'm > on the road, I can't have that, because FreeBSD will scream into single > user mode if that partition isn't there. I could put a 'noauto' switch > into fstab, but that still leaves me with the problem: Just a (rather crude) quickhack: #!/bin/sh SLEEP=300 MOUNTED=0 while [ 1 ]; do sleep $SLEEP if [ $MOUNTED = 0 ]; then mount -t ufs2 /dev/ad4s1d /hd2 >/dev/null 2>&1 if [ $? = "0" ]; then MOUNTED=1 fi else touch /hd2/.touchme >/dev/null 2>&1 if [ $? = "1" ]; then umount -f /hd2 >/dev/null 2>&1 MOUNTED=0 fi fi done Basically, this'll try every $SLEEP seconds to either mount the disk or, once this has been done successfully, to touch a file on /hd2. If that fails, the disk's no longer there, so force-unmount it. I can't really test it, so I'm none too sure this works, though. :( HTH, Mario