Date: Thu, 06 Dec 2012 15:43:13 -0800 From: "Ronald F. Guilmette" <rfg@tristatelogic.com> To: freebsd-questions@freebsd.org Subject: Re: List all hard drives on system (with capacities)... How? Message-ID: <9477.1354837393@tristatelogic.com> In-Reply-To: <50C12B6C.5020109@tundraware.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <50C12B6C.5020109@tundraware.com>, Tim Daneliuk <tundra@tundraware.com> 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 drive >s, >> 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 Thank you Tim. Silly me! Before I even got your reply, I had already doen a bit more research and I had found what I think may perhaps be an even better answer. I never knew about this utility program called "diskinfo", but I just now found it, and it seems to do the trick. There appears to be a small problem with using fdisk -s... It looks like it hiccups when and if the drive in question has not actually been partitioned yet: # fdisk -s /dev/ad6 fdisk: invalid fdisk partition table found (The diskinfo utility apparently does not suffer from this problem.)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9477.1354837393>