From owner-freebsd-geom@FreeBSD.ORG Tue Sep 7 18:13:31 2010 Return-Path: Delivered-To: geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5283310656EC for ; Tue, 7 Sep 2010 18:13:31 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 85A0B8FC26 for ; Tue, 7 Sep 2010 18:13:30 +0000 (UTC) Received: by bwz20 with SMTP id 20so5276608bwz.13 for ; Tue, 07 Sep 2010 11:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :x-enigmail-version:content-type:content-transfer-encoding; bh=BEJemUbxLZrHPQxskU3oUPflwco+whIiqAIVnBpwiyc=; b=Rzfh9SwXlUHR5urSfxdNDLkFGmzWOwxHl3ZdvP0kva6Gl4v7N8gdJGA9/B9Ocu+f+D D7Md2mOI/tuY/igBRg7p/gzVe9aineNPdZmJW6B/Jq375mkIL1foa4jVzLP1fQSEeNUf 0a8QT4vz3VIAoM0eP3C6Uc8F3hCKpDfQaXfJM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=CiKWMnl8GowoEndWd3CFyFPB5LfpyD2BHuKiWTmrdICOd7y0ByI+saTnZukTlos9CJ giL36zy2ccAYQ9nqQMhyNpGZB1yeUbBeiLe5CKEY910prl4xkBjyKMlO1N+zROgr69Pv Hws0cn3fq4FnbjGlAE4wGQO+aaXDum14M1wMs= Received: by 10.204.85.89 with SMTP id n25mr4253560bkl.105.1283879858782; Tue, 07 Sep 2010 10:17:38 -0700 (PDT) Received: from mavbook.mavhome.dp.ua (pc.mavhome.dp.ua [212.86.226.226]) by mx.google.com with ESMTPS id 11sm5484291bkj.11.2010.09.07.10.17.36 (version=SSLv3 cipher=RC4-MD5); Tue, 07 Sep 2010 10:17:37 -0700 (PDT) Sender: Alexander Motin Message-ID: <4C8673A0.6070605@FreeBSD.org> Date: Tue, 07 Sep 2010 20:17:20 +0300 From: Alexander Motin User-Agent: Thunderbird 2.0.0.24 (X11/20100402) MIME-Version: 1.0 To: Alexander Leidinger References: <20100907170526.834646wxfkh4sou8@webmail.leidinger.net> In-Reply-To: <20100907170526.834646wxfkh4sou8@webmail.leidinger.net> X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: geom@FreeBSD.org Subject: Re: Determinig removable devices in shell scripts? X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2010 18:13:31 -0000 Hi. 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". There is two kinds of removability - removable media and removable device. For removable media: SCSI/ATAPI disks (da) report different device types for fixed disks (HDD) and removable (ZIP, FDD, card readers, ...). It can be found via `camcontrol inquiry daX`. I haven't heard about ATA (non-ATAPI) disks with removable media, though specifications last time include dedicated fields for media serial number, which may mean removable media. For removable devices: I believe it is controller of even more - platform dependent. For USB it probably may be assumed by default, for others it depends. All I have seen - AHCI controller have two bits per port defining different kind of removability. You may see them during verbose boot. But BIOS vendors often not bothering to fill them correctly even if some ports wired to external connectors. To get information about controller, you may try `camcontrol negotiate ada0 -v`. -- Alexander Motin