2

I run the command df -g to get the GB block sizes in the second column (left to right). If I want to get the total capacity for all hard disks, which command should I use?

OS is AIX.

1
  • Which OS? I'm guessing Linux?
    – growse
    Mar 31, 2011 at 14:15

6 Answers 6

2
for i in `lspv | awk '{print $1}'`
do
    echo $i
    lsattr -El -a size_in_mb $i
done

Or via ODM:

odmget -q"name like hdisk* and attribute=size_in_mb" CuAt
2

Total size of all disks (sum). Output in GB.

TOTAL=0; for DISK in $(lspv | awk '{ print $1 }');do SIZE=$(bootinfo -s $DISK); TOTAL=$(echo "$TOTAL + $SIZE"|bc); done; echo "$TOTAL / 1024" | bc

Used Commands
lspv: lists all disks
bootinfo -s: gives you the real size of the disk
bc: used for calculating

1
  • 1
    Thank you for this. However, we do prefer at least a little explanation (such as what command you're getting the data from, I assume lspv plus bootinfo) and the reason for the scripting around it. Nonetheless, an upvote to you. Jun 4, 2014 at 11:00
1

For AIX try the following, which does NOT need to be run as root:

get_conf DISK_SIZE /dev/hdisk0

The output will be returned in MB.

1
  • In case someone's still looking for the answer, it is getconf now in AIX 7.2 Oct 11, 2023 at 23:36
0

The following command will help you to find total size of each hdd on your system.

fdisk -l  | grep Disk
0

I know you didn't ask this directly but df -h lists created partition sizes which is sometimes more useful.

-1

Not sitting in front of an AIX system, but try this:

df --total -h

Edit: this won't work in AIX. But I'll leave this here for anyone else who might need it on GNU systems.

2
  • 2
    AIX commands don't support GNU like parameters.
    – Benoit
    Mar 31, 2011 at 15:18
  • hmmmm .... I thought that was too easy ... Mar 31, 2011 at 16:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .