List all hard drives on system (with capacities)... How?
Nikos Vassiliadis
nvass at gmx.com
Thu Dec 6 23:59:09 UTC 2012
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
More information about the freebsd-questions
mailing list