From owner-freebsd-geom@FreeBSD.ORG Wed Sep 8 12:32:26 2010 Return-Path: Delivered-To: freebsd-geom@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 75F4110656B4 for ; Wed, 8 Sep 2010 12:32:26 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id E80488FC19 for ; Wed, 8 Sep 2010 12:32:25 +0000 (UTC) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.3/8.14.3) with ESMTP id o88CW9tO028521; Wed, 8 Sep 2010 14:32:24 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.3/8.14.3/Submit) id o88CW9RX028520; Wed, 8 Sep 2010 14:32:09 +0200 (CEST) (envelope-from olli) Date: Wed, 8 Sep 2010 14:32:09 +0200 (CEST) Message-Id: <201009081232.o88CW9RX028520@lurza.secnetix.de> From: Oliver Fromme To: freebsd-geom@FreeBSD.ORG, Alexander@leidinger.net In-Reply-To: <20100907170526.834646wxfkh4sou8@webmail.leidinger.net> X-Newsgroups: list.freebsd-geom User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.4-PRERELEASE-20080904 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.5 (lurza.secnetix.de [127.0.0.1]); Wed, 08 Sep 2010 14:32:24 +0200 (CEST) Cc: Subject: Re: Determinig removable devices in shell scripts? X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-geom@FreeBSD.ORG, Alexander@leidinger.net List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Sep 2010 12:32:26 -0000 Alexander Leidinger wrote: > is there an easy way to determine in a shell script if a device > (da/ada) is removable (USB memory stick, eSATA connection)? I was > thinking more or less about something like "sysctl kern.disks". USB devices are easy, just check if the da(4) device is connected to umass. I think camcontrol will tell you. Same with FireWire devices via sbp(4). eSATA might be more difficult. Finally, there are cases where it's pretty much impossible to detect. I've got a hot-swap frame for P-ATA hard drives which I use for backups, using atacontrol(8) attach/detach/ reinit, so it's basically a removable device. But it's completely transparent to the OS, i.e. there is no way to determine if a certain ad(4) device is located in such a swappable frame or not. Well ... if the device was not present during boot (see /var/run/dmesg.boot), then it is obviously removable, but the reverse isn't true since a removable device might be already present during boot, so that's not a complete solution to the problem. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd One Unix to rule them all, One Resolver to find them, One IP to bring them all and in the zone to bind them.