From owner-freebsd-questions@FreeBSD.ORG Mon Jun 23 17:25:48 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 BEB8A106566C for ; Mon, 23 Jun 2008 17:25:48 +0000 (UTC) (envelope-from heroh@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id 25E288FC1C for ; Mon, 23 Jun 2008 17:25:47 +0000 (UTC) (envelope-from heroh@gmx.de) Received: (qmail invoked by alias); 23 Jun 2008 17:25:46 -0000 Received: from e178202234.adsl.alicedsl.de (EHLO [10.0.0.100]) [85.178.202.234] by mail.gmx.net (mp058) with SMTP; 23 Jun 2008 19:25:46 +0200 X-Authenticated: #31543762 X-Provags-ID: V01U2FsdGVkX1/+W01ywTj+72DKezoD6F6CWg7P+njR9LbPAo+Ohb B0kcNE9b8hX/cB From: Helge Rohde To: rsmith@xs4all.nl Date: Mon, 23 Jun 2008 17:25:58 +0000 User-Agent: KMail/1.9.7 References: <200806212144.09925.heroh@gmx.de> <20080621224731.GA26997@slackbox.xs4all.nl> In-Reply-To: <20080621224731.GA26997@slackbox.xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200806231725.58862.heroh@gmx.de> X-Y-GMX-Trusted: 0 Cc: freebsd-questions@freebsd.org Subject: Re: shellscript conditional to check for external disk 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: Mon, 23 Jun 2008 17:25:48 -0000 On Saturday 21 June 2008 22:47:31 Roland Smith wrote: > On Sat, Jun 21, 2008 at 09:44:09PM +0000, Helge Rohde wrote: > > Hello List, > > > > I need to write a backup script, and one of the required actions would be > > a copy of the backup to an external firewire drive. I would like to make > > this as easy as possible for the local staff, so i'd like to check > > whether the drive is attached, if necessary mount it, copy over the > > backup and unmount it again, so that the local staff can swap the > > external disks when they're not used. > > > > Is there a canonical way to achieve what i want? I played with the idea > > of simply checking for /dev/da0s1d's existance, but that won't disappear > > on disconnect, so that would leave the is a possibility that although > > da0 is in /dev, it might not be connected. > > Use glabel(8) to give the device an unique label. There is no telling > which device /dev/da0s1d is pointing to! After labeling you can check > for /dev//, which should be unique. > > Make sure to unmount the drive at the end of the backup script, or > you'll get a kernel panic when staff pulls the plug on a mounted device. > > Roland Okay, it obviosly makes sense to use glabel instead of the device node. Will the glabel appear/disappear depending on whether the drive is connected? Is it possible to have more then one physical drive with the same glabel(As i plan to utilize two identical Firewire disks) ? Either way, i still need a way to check whether a drive is attached or not. Mounting( and unmounting!) will be done from the periodic backup scripts. I am not sure how devd could help me with that, besides maybe write/delete a zero-byte file somewhere and have the periodic script check for its existence. Thank you all for your help, Helge