Operating System - HP-UX
1748125 Members
3133 Online
108758 Solutions
New Discussion юеВ

To fing harddisk size in GB

 
Logesh_1
Occasional Advisor

To fing harddisk size in GB

Hi.,

Please tell me the command to find the hardisk space in GB(GIGA BYTE)in hpux


Logesh.S
8 REPLIES 8
Patrick Wallek
Honored Contributor

Re: To fing harddisk size in GB

The easiest way is to do a 'diskinfo' on the /dev/rdsk/c?t?d? device file. That will give you the disk size and from there you can calculate the GB size of the disk.

# diskinfo /dev/rdsk/c8t0d2
SCSI describe of /dev/rdsk/c8t0d2:
vendor: HP
product id: A6218A
type: direct access
size: 37748736 Kbytes
bytes per sector: 512

From here you can get the size in GB by dividing the size by 1,048,576.

37,748,736 KB / 1,048,576 = 36 GB
Michael Steele_2
Honored Contributor

Re: To fing harddisk size in GB

echo "selclass qualifier disk;info;wait;infolog" | cstm

-or-

Patrick's works just as well.
Support Fatherhood - Stop Family Law
Logesh_1
Occasional Advisor

Re: To fing harddisk size in GB

Thanks for the quick reply,instaed of this command any other command is there to find out the harddisk space in GB
Steven Schweda
Honored Contributor

Re: To fing harddisk size in GB

"man df"? I assume that you can get from KB
("df -k") to GB.
Logesh_1
Occasional Advisor

Re: To fing harddisk size in GB

HI,

The df -k command shows the harddisk capacity in kb not in GB
Davis Paul
Valued Contributor

Re: To fing harddisk size in GB

Hi Logesh ,
To get the disk size in GB use the command:
diskinfo /dev/rdsk/c2t0d0s2 |grep size: > /tmp/sad;A=$(cat /tmp/sad |grep size: | awk '/ / {print $2}');Z=1024;(( B = A / Z ));(( C = B / Z ));echo "$C GB"
-where /dev/rdsk/c2t0d0s2 is the device file of the disk. You can use it as a script.
Regards,
Davis Paul.

Hein van den Heuvel
Honored Contributor

Re: To fing harddisk size in GB

Logesh,
Where you looking for a truncated integer result or a fractional result?
How do you see your 'harddisk'?
df?
pvdisplay?
diskinfo?
What works for you?


Steve>> "man df"? I assume that you can get from KB
("df -k") to GB.

I don't think Logesh can. That's the problem.
Also, df can do the nastly line split making scripts trickier.


>>>>

diskinfo /dev/rdsk/c2t0d0s2 |grep size: > /tmp/sad;A=$(cat /tmp/sad |grep size: | awk '/ / {print $2}');Z=1024;(( B = A / Z ));(( C = B / Z ));echo "$C GB"


10 points for entertainment!
0 points for efficiency

untested (as I have no privs here...)

# let size_in_gb=$(diskinfo -b)/1024/1024



>> cat /tmp/sad |grep size: | awk '/ / {print $2}'

awk is happy to read the file (or pipe) itself
awk is made to grep itself

awk '/size/{ print $2}' /tmp/sad

and why use an intermediate file, or that redundant grep?

A=$(diskinfo /dev/rdsk/c2t0d0s2 |awk '/size/{ print $2}');Z=1024;(( B = A / Z ));(( C = B / Z ));echo "$C GB"

The Z intermediete only obfuscates.

But in the end... Just ask diskinfo for the size alone!

hein.



Arturo Galbiati
Esteemed Contributor

Re: To fing harddisk size in GB