Storage‎ > ‎Storage-disk‎ > ‎

Solaris disk size

Thank you for visiting this page, this page has been update in another link How to get disk size on Solaris
Here are ways to get a single disk size on Solaris.

HD utility

For system disk
# hd -t c0t0

        0     1     2     3     4     5     6     7     8     9   total
c0t0  1.0G   40G  931G  4.9G  9.8G  3.9G   16M  872G   16M    0K  932G

For disk used in ZFS
# hd -t c0t1

        0     1     2     3     4     5     6     7     8     9   total
c0t1  932G    0K    0K    0K    0K    0K    0K    0K  8.0M    0K  932G 

But, it doesn't work well with disk size greater than 2TB, that's another interesting topic.

# hd -t c0t1
        0     1     2     3     4     5     6     7     8     9   total
c0t1  1.8T    0K    0K    0K    0K    0K    0K    0K  8.0M    0K 8192E
# hd -t c0t1
        0     1     2     3     4     5     6     7     8     9   total
c0t1  1.8T    0K    0K    0K    0K    0K    0K    0K  8.0M    0K 81
92E

iostat -En c0t0d0

# iostat -En c0t0d0
c0t0d0           Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Vendor: ATA      Product: HITACHI H7220AA3 Revision: A26D Serial No: 
Size: 2000.40GB <2000398933504 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 2 Predictive Failure Analysis: 0

The weak side of this is that if there is no error from the disk you specified, then the command returns nothing to you.

prtvtoc

# prtvtoc /dev/dsk/c0t1d0
* /dev/dsk/c0t1d0 partition map
*
* Dimensions:
*     512 bytes/sector
* 3907029167 sectors
* 3907029100 accessible sectors
*
* Flags:
*   1: unmountable
*  10: read-only
*
* Unallocated space:
*       First     Sector    Last
*       Sector     Count    Sector
*          34       222       255
*
*                          First     Sector    Last
* Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
       0      4    00        256 3907012494 3907012749
       8     11    00  3907012750     16384 3907029133

Then, do a bit math, sector size * sectors = 512*3907029167=2000398933504=2TB

fdisk

# fdisk -G /dev/rdsk/c0t1d0p0
* Physical geometry for device /dev/rdsk/c0t1d0p0
* PCYL     NCYL     ACYL     BCYL     NHEAD NSECT SECSIZ
  60800    60800    0        0        255   252   512  

Do math again, NCLY * NHEAD * NSECT * NSECSIZ

60800 * 255 * 252 * 5122000388096000

Here is a simple scritp can do 

#!/bin/bash
#ncyl=$2 nhead=$5 nsect=$6 secsz=$7
fdisk -G /dev/rdsk/c4t7d0p0 | tail -1 | awk '{
bytes=$2*$5*$6*$7;
printf("%7d MiB %7d MB\n", bytes/1024/1024, bytes/1000/1000);
}'

fdisk -G /dev/rdsk/c4t7d0p0 | tail -1 | awk '{
bytes=$2*$5*$6*$7;
printf("%7d MiB %7d MB\n", bytes/1024/1024, bytes/1000/1000);
}'
 953859 MiB 1000194 MB


Comments