Operating System - HP-UX
1748286 Members
3324 Online
108761 Solutions
New Discussion юеВ

calculating total and free disk space on a system

 
SOLVED
Go to solution
Amit Manna_4
Occasional Advisor

calculating total and free disk space on a system

hi
Is there any script for calculating the total and free disk space left on a HP Unix system

Regards
14 REPLIES 14
James R. Ferguson
Acclaimed Contributor

Re: calculating total and free disk space on a system

Hi Amit:

Define "free".

If you mean "free" spaces within mounted filesystems, use 'bdf'. If you mean free physical disk extents within LVM volume groups, start with 'vgdisplay'. If you mean "unused" physical disks, tell us how you know they are truly unused if they could be raw volumes.

Regards!

...JRF...
Amit Manna_4
Occasional Advisor

Re: calculating total and free disk space on a system

HI James
I want to calculate the free space in the VGs.

When we give vgdisplay command we get alloc Pe and Free PE.

I want to calculate the sum of all free space left and total allocated space left in VG.
I am looking for a script to do so

Regards
Amit Manna


Vishu
Trusted Contributor

Re: calculating total and free disk space on a system

Hi Amit,

What output you want exactly. Free disk space in a VG, you can find with vgdisplay command. In a disk, you can find with pvdisplay command. bdf tells you the free space in the FS.

Or, please elaborate your question on what else you need.

Vishu
Trusted Contributor

Re: calculating total and free disk space on a system

**When we give vgdisplay command we get alloc Pe and Free PE.**

vgdisplay will tell this information only i.e.

Total PE - Total disk space alloted to that VG.

Alloc PE - Disk space allocated to LVs in that VG.

Free PE - Unused Disk space in that VG.

But you need to see the PE size of that VG, which helps you calculate the space in MB. To calculate the space, use the formula:-

Space(MB) = PE Size * No. of PEs
Roopesh Francis_1
Trusted Contributor

Re: calculating total and free disk space on a system

vgdisplay|grep "VG Name"|awk '{print $3}|'|while read a
do
vgdisplay $a|grep "PE Size"|awk '{print $4}'|read b
vgdisplay $a|grep "Total PE"|awk '{print $3}'|read c
vgdisplay $a|grep "Free PE"|awk '{print $3}'|read d
echo "$a $(b*c) $(b*d)"
done

first column will be vg name second column will be total size of vg and third column will be free space in VG
Vinod Kumar Yadav
Trusted Contributor

Re: calculating total and free disk space on a system

Hi,

For Calculating Total Disk with & Free Disk Space with the VG.


Please follow the below step.
Run the command vgdiaply

#root # vgdisplay
--- Volume groups ---
VG Name /dev/vg00
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 17
Open LV 17
Max PV 16
Cur PV 4
Act PV 4
Max PE per PV 4384
VGDA 8
PE Size (Mbytes) 4
Total PE 17394
Alloc PE 6019
Free PE 11375
Total PVG 2
Total Spare PVs 0
Total Spare PVs in use 0

Cur PV - 4 - Means 4 Disk are using with the VG00

Free PE - 11375 - Means Free space Avilable on the VG.

For Calcuting the Total Free Space in the VG
is.

PE Size * Free PE = Total Free Space

Example - 4*11375 = 45500 is the Free Space in the VG


Thanks
Vinod Kumar Yadav



Jai Shiv Shankar
Roopesh Francis_1
Trusted Contributor

Re: calculating total and free disk space on a system

small correction in the previous post
vgdisplay|grep "VG Name"|awk '{print $3}|'|while read a
do
vgdisplay $a|grep "PE Size"|awk '{print $4}'|read b
vgdisplay $a|grep "Total PE"|awk '{print $3}'|read c
vgdisplay $a|grep "Free PE"|awk '{print $3}'|read d
echo "$a $((b*c)) $((b*d))"
done

first column will be vg name second column will be total size of vg and third column will be free space in VG









Amit Manna_4
Occasional Advisor

Re: calculating total and free disk space on a system

The above is not working


Regards
Amit Manna
Roopesh Francis_1
Trusted Contributor

Re: calculating total and free disk space on a system

paste the output