From owner-freebsd-questions@FreeBSD.ORG Sun Jun 22 16:50:35 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 36376106566B for ; Sun, 22 Jun 2008 16:50:35 +0000 (UTC) (envelope-from camiloreyes82@yahoo.com) Received: from web63908.mail.re1.yahoo.com (web63908.mail.re1.yahoo.com [69.147.97.123]) by mx1.freebsd.org (Postfix) with SMTP id E008D8FC17 for ; Sun, 22 Jun 2008 16:50:34 +0000 (UTC) (envelope-from camiloreyes82@yahoo.com) Received: (qmail 27508 invoked by uid 60001); 22 Jun 2008 16:50:33 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Received:X-Mailer:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Message-ID; b=45QQlHJh1CR33A4UAdOADLQagrWXabJyHhyyP6OzoOOgoGdsBkym+cqIT9dyFTv9TmFHQSM3hU0+xUlYH1kVyQ7mceBdojGBatj5sKmU4TbDYNv9rlwh19cUM1jdtlKXjcpSUVjfAPNDb5TTHXP+OQycY5pzS9avRQ9mJr3yzgU=; Received: from [98.201.109.92] by web63908.mail.re1.yahoo.com via HTTP; Sun, 22 Jun 2008 09:50:33 PDT X-Mailer: YahooMailWebService/0.7.199 Date: Sun, 22 Jun 2008 09:50:33 -0700 (PDT) From: Camilo Reyes To: freebsd-questions@freebsd.org In-Reply-To: <20080622120011.F06D41065747@hub.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Message-ID: <934542.25023.qm@web63908.mail.re1.yahoo.com> Subject: Re: shellscript conditional to check for external disk X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: camiloreyes82@yahoo.com List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Jun 2008 16:50:35 -0000 You can use /var/log/messages to check for the existence of an external drive through a series of grep commands. Here is my log output when I insert/remove a USB drive: Jun 22 11:44:49 Christi kernel: umass0: on uhub4 Jun 22 11:44:49 Christi root: Unknown USB device: vendor 0x0781 product 0x5150 b us uhub4 Jun 22 11:44:49 Christi kernel: da0 at umass-sim0 bus 0 target 0 lun 0 Jun 22 11:44:49 Christi kernel: da0: Removable Direct Access SCSI-2 device Jun 22 11:44:49 Christi kernel: da0: 40.000MB/s transfers Jun 22 11:44:49 Christi kernel: da0: 122MB (250879 512 byte sectors: 64H 32S/T 1 22C) Jun 22 11:44:49 Christi kernel: GEOM_LABEL: Label for provider da0s1 is msdosfs/ . Jun 22 11:44:56 Christi kernel: umass0: at uhub4 port 2 (addr 2) disconnected Jun 22 11:44:56 Christi kernel: (da0:umass-sim0:0:0:0): lost device Jun 22 11:44:56 Christi kernel: (da0:umass-sim0:0:0:0): removing device entry Jun 22 11:44:56 Christi kernel: GEOM_LABEL: Label msdosfs/ removed. Jun 22 11:44:56 Christi kernel: umass0: detached I'm sure you can come up with creative ways to write a script that checks for when the disk is detached. "Bono Vince Malum" -- -Camilo > Date: Sat, 21 Jun 2008 21:44:09 +0000 > From: Helge Rohde > Subject: shellscript conditional to check for external disk > To: freebsd-questions@freebsd.org > Message-ID: <200806212144.09925.heroh@gmx.de> > Content-Type: text/plain; charset="us-ascii" > > 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. > > Any ideas or RTFM-pointers? > > Helge