How to check disk size in Solaris?

We need to use different commands to check the disk size on different flavors of UNIX.

For example

In AIX – bootinfo -s diskname
In HPUX – diskinfo -b diskname

But in Solaris, there is no straight forward command to check the disk size. We need to calculate the size from the output of prtvtoc command

Following sample script will do the job for us

if [ $# -ne 1 ]
then
echo “Usage disksize.sh ”
echo “NOTE: Do not specify disk path”
else
CLY=`prtvtoc /dev/rdsk/$1 grep “accessible” cut -d”*” -f2 sed ‘s/^[ \t]*//’ cut -d” ” -f1`
SEC=`prtvtoc /dev/rdsk/$1 grep “sectors/cylinder” cut -d”*” -f2 sed ‘s/^[ \t]*//’ cut -d” ” -f1`
BYT=`prtvtoc /dev/rdsk/$1 grep “bytes/sector” cut -d”*” -f2 sed ‘s/^[ \t]*//’ cut -d” ” -f1`
SIZ=`expr $CLY “*” $SEC “*” $BYT`
SIZMB=`expr $SIZ / 1024 / 1024`
echo “Disk Size $SIZMB (mb)”
fi


#./disksize.sh c2t20120002AC000212d74s2
Disk Size 5119 (mb)

Note: If you see the error(s) like prtvtoc: /dev/rdsk/c1t200400A0B81843A2d12s2: Unable to read Disk geometry errno = 0x16, then most likely the storage Array is configured in Active / Passive mode, which allows the I/O to happen only on active path (when the active path is enabled).

This utility will have to executed on the active path.

How to find active Disk path?

Option 1
========

If you have volume manager like VxVM, use vxdisk utility

# vxdisk list c1t200400A0B81843A2d12s2
Device: c1t200400A0B81843A2d12s2
devicetag: c1t200400A0B81843A2d12
type: auto
info: format=none
flags: online ready private autoconfig invalid
pubpaths: block=/dev/vx/dmp/c1t200400A0B81843A2d12s2 char=/dev/vx/rdmp/c1t200400A0B81843A2d12s2
guid: –
udid: IBM%5F1724-100%20%20FAStT%5F600A0B80001843A10000000044B61E57%5F600A0B800018436B000001E24B9F086D
site: –
Multipathing information:
numpaths: 4
c2t200500A0B81843A2d12s2 state=enabled type=primary
c2t200400A0B81843A2d12s2 state=enabled type=secondary
c1t200500A0B81843A2d12s2 state=enabled type=primary
c1t200400A0B81843A2d12s2 state=enabled type=secondary


Number of paths are 4 (2 Primary & 2 Secondary)

You can use any of the primary paths (c2t200500A0B81843A2d12s2 / c1t200500A0B81843A2d12s2)

bash-3.00# ./disksize.sh c2t200500A0B81843A2d12s2
Disk Size 255992 (mb)
bash-3.00# ./disksize.sh c1t200500A0B81843A2d12s2
Disk Size 255992 (mb)

Option 2
========

Use utility like luxadm (I’ve tested this only on Solaris, other *nix may have similar utilities)

# luxadm disp /dev/rdsk/c1t200400A0B81843A2d12s2
DEVICE PROPERTIES for disk: /dev/rdsk/c1t200400A0B81843A2d12s2
Vendor: IBM
Product ID: 1724-100 FAStT
Revision: 0542
Serial Num: 1T62393367
Unformatted capacity: 256000.000 MBytes
Write Cache: Enabled
Read Cache: Enabled
Minimum prefetch: 0x1
Maximum prefetch: 0x1
Device Type: Disk device
Path(s):

This utility shows the paths, not primary / secondary options. So we may have to try using all of them.

/dev/rdsk/c1t200400A0B81843A2d12s2
/devices/pci@12,600000/SUNW,qlc@0/fp@0,0/ssd@w200400a0b81843a2,c:c,raw
LUN path port WWN: 200400a0b81843a2
Host controller port WWN: 2100001b3286dfd8
Path status: O.K.
/dev/rdsk/c1t200500A0B81843A2d12s2
/devices/pci@12,600000/SUNW,qlc@0/fp@0,0/ssd@w200500a0b81843a2,c:c,raw
LUN path port WWN: 200500a0b81843a2
Host controller port WWN: 2100001b3286dfd8
Path status: O.K.
/dev/rdsk/c2t200400A0B81843A2d12s2
/devices/pci@12,600000/SUNW,qlc@0,1/fp@0,0/ssd@w200400a0b81843a2,c:c,raw
LUN path port WWN: 200400a0b81843a2
Host controller port WWN: 2101001b32a6dfd8
Path status: O.K.
/dev/rdsk/c2t200500A0B81843A2d12s2
/devices/pci@12,600000/SUNW,qlc@0,1/fp@0,0/ssd@w200500a0b81843a2,c:c,raw
LUN path port WWN: 200500a0b81843a2
Host controller port WWN: 2101001b32a6dfd8
Path status: O.K.

Advertisements
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

3 Responses to How to check disk size in Solaris?

  1. anon4cec says:

    thanks, & nice script. solaris 8 (at least) requires the pipes for cut, grep, & sed programs. I would try to update the script to include a scan and print for all disks then have the output be in the form of a table & use GB human readable format if I get time. I will post back if I do.

  2. enigmaticoders says:

    Thats quite a helpful command (prtvtoc)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s