Summary : Script for detemining disk size

From: Bigadmin <bigadmin_at_unixplanet.biz>
Date: Sat Sep 27 2008 - 19:31:28 EDT
Thanks to every one for quick response including Mathew , Noel,  Jeffrey ,
John , francisco , Kev and Daniel.

 

I was trying to determine disk size with format command while prtvtoc does
this job.

The other problem was converting sector count to MB or GB because prtvtoc or
format only returns disk information

In Sector, Cylinder and Tracks.

 

Here is the responses that I received.

Thanks again for help.

 

*******************************************************************

*******************************************************************

 

* /dev/rdsk/c1t0d0s2 partition map

*

* Dimensions:

*     512 bytes/sector

*     848 sectors/track

*      24 tracks/cylinder

*   20352 sectors/cylinder

*   14089 cylinders

*   14087 accessible cylinders

*

* Flags:

*   1: unmountable

*  10: read-only

*

*                          First     Sector    Last

* Partition  Tag  Flags    Sector     Count    Sector  Mount Directory

       0      2    00   40968576  61442688 102411263

       1      3    01          0  40968576  40968575

       2      5    00          0 286698624 286698623

       3      0    00  102411264     40704 102451967

       7      0    00  102451968 184246656 286698623

 

"Accessible Cylinders" * "Sectors/Cylinders" = Total Number of Sectors

(ie: typically the Sector Count of partition 2)

 

"Accessible Cylinders" * "Sectors/Cylinders" * "Bytes/Sector" = Total Number
of Bytes on Disk.  (Divide by 1,000,000 for MiB.  Divide by 1,000,000,000
for GiB)

 

% prtvtoc /dev/rdsk/c1t0d0s2 | awk '/bytes\/sector/ {bytes=$2}
/sectors\/cylinder/ {sectors = $2} /accessible cylinders/ {cylinders = $2}
END { print bytes * sectors * cylinders }'

146789695488

 

% sudo prtvtoc /dev/rdsk/c1t0d0s2 | awk '/bytes\/sector/ {bytes=$2}
/sectors\/cylinder/ {sectors = $2} /accessible cylinders/ {cylinders = $2}
END { print bytes * sectors * cylinders / 1000000000 }'

146.79

 

*******************************************************************

*******************************************************************

 

for disk in /dev/rdsk/c*2

do

rawsize=$(sudo prtvtoc $disk |awk '$4 == 0 {print $0}'|sort -n +5|tail
-1|awk '{print $6}')

if [ "$rawsize" != "" ]

then

rawsize=$(( $rawsize / 2 / 1048576 ))

echo $disk is $rawsize GB

else

echo $disk was not found, moving on

fi

done

 

 

************************************************************************  

***********************************************************************  

 

#!/usr/bin/ksh

echo | format | grep -i c.*t.*d.* | grep -v disk | awk '{print $2}' >
/tmp/.disklist.$$

for Disk in $(cat /tmp/.disklist.$$)

do

        Sectors=$(prtvtoc -s /dev/rdsk/${Disk}s2 | sed -n '/      2/p' |grep
" 5 " | awk '{printf "has %d sectors\n",$5}')

        echo ${Disk} ${Sectors}

done

rm -f /tmp/.disklist.$$

 

 

******************************************************************* 

******************************************************************* 

 

ls /dev/rdsk/*s2 | sed -e "s/^/prtvtoc -h /" | sh -x

 

******************************************************************* 

*******************************************************************

 

for i in `ls /dev/rdsk/*s2`; do prtvtoc $i | grep "       2 " | awk '{ print
$6(2*1000*1000) }' ; done
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Sat Sep 27 19:34:14 2008

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:44:12 EST