From owner-freebsd-questions@FreeBSD.ORG Thu Dec 6 23:59:09 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 93D80ACC for ; Thu, 6 Dec 2012 23:59:09 +0000 (UTC) (envelope-from nvass@gmx.com) Received: from mailout-eu.gmx.com (mailout-eu.gmx.com [213.165.64.42]) by mx1.freebsd.org (Postfix) with SMTP id D4C408FC15 for ; Thu, 6 Dec 2012 23:59:08 +0000 (UTC) Received: (qmail invoked by alias); 06 Dec 2012 23:59:07 -0000 Received: from 188.4.178.221.dsl.dyn.forthnet.gr (EHLO [192.168.1.77]) [188.4.178.221] by mail.gmx.com (mp-eu001) with SMTP; 07 Dec 2012 00:59:07 +0100 X-Authenticated: #46156728 X-Provags-ID: V01U2FsdGVkX19u2Zgk5hVuMaWKpa3iN8jHcR59MKU7nySzcAUnT/ XXUHntxZzuaVfl Message-ID: <50C1313C.4000201@gmx.com> Date: Fri, 07 Dec 2012 01:58:52 +0200 From: Nikos Vassiliadis User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Tim Daneliuk Subject: Re: List all hard drives on system (with capacities)... How? References: <9304.1354836633@tristatelogic.com> <50C12B6C.5020109@tundraware.com> In-Reply-To: <50C12B6C.5020109@tundraware.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 Cc: freebsd-questions@freebsd.org, "Ronald F. Guilmette" X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Dec 2012 23:59:09 -0000 On 12/7/2012 1:34 AM, Tim Daneliuk wrote: > On 12/06/2012 05:30 PM, Ronald F. Guilmette wrote: >> >> I'd like to write a small program or shell script that simply lists all >> of the physical hard drives attached to the local system, along with >> their >> product identifiers and their respective capacities. >> >> The following simple script works well for both PATA/SATA and USB hard >> drives, >> but it does not list drive capacities: >> >> #!/bin/sh >> >> atacontrol list | grep ': ad[0-9]' | sed 's/^.*: //' >> camcontrol devlist | grep '(da[0-9]' | sed -E 's/^(.*) >> \((da[0-9]+).*$/\2 \1/' >> >> >> How can I modify the script above in order to get it to print out the >> respective drive capacities? > > Look into fdisk -s > > I think fdisk should need a valid partition table, or not? diskinfo works nice with all disk-like devices be it a physical disk, a slice, a partition, a swap-backed device etc. Its output is easily parsable using a single line per device and if you use -v you will get the same info in human-readable form. HTH, Nikos