Determining number of hard disks in the system

Hello to all,

what is the command in Solaris/Unix which I can use to determine how many hard disks exist in the system?
I have tried with different command such as df -lk and similar but cannot know for sure how many actual disks are installed.

Commands like # fdisk -l | grep Disk and # lshw -short -C disk doesn't work in Solaris.

Thank you.

You are maybe using pools... type zpool list to see...

Unfortunately, this is not it. I receive "no pools" result.

Try

format

or

cfgadm

yeah, after format just count the number of disk? There is actually already a count, however it starts with zero. So just add +1 to what ever number is present in format.

Yes...

How about?

ls /dev/[sh]d*[!0-9]

If you just need the number:

ls /dev/[sh]d*[!0-9]|wc -l

Hope ths helps

/dev/hd* /dev/sd* is a very linux-specific answer. Not all systems use those device names. For that matter, even Linux doesn't use those all the time -- some RAID cards will give funny names. In Linux, you can check for all block devices in /sys/class/block, and filter out irrelevant ones by looking deeper in /sys/class/block/[device].

Any good answer will have to be system-specific, because this is a management question, not a system environment one.

This is a Solaris box but is it SPARC or x86?

If SPARC does it have a System Controller? (SC> prompt)

This will give you the count and some more information about each disk on a Solaris machine:

iostat -En|awk '/^c[0-9]/{printf("\n%3d : ",++d)}{gsub("  *"," ");gsub("[A-Za-z ][A-Za-z ]*: 0 ","");printf("%s ",$0)}END{printf("\n")}'
1 Like

you should be able to use

iostat -En
1 Like

Thank you all for the feedback. However this last command didn't help me.
In fact I was trying this command: df -lk, and when execute this command I get this results:

File system 1024-blocks Used Available Capacitiy Mounted on
/dev/dsk/c0t0d0s0 ............................................................................... /
/devices ................................................................................................ /devices
ctfs .........................................................................................................../system/contract
.
.
.
.
.
.
.
/dev/dsk/c0t0d0s3 ....................................................................................../tmp
/dev/dsk/c0t1d0s0 ....................................................................................../inglog
/dev/dsk/c0t0d0s5......................................................................................
/dev/dsk/c0t0d0s4......................................................................................
/dev/dsk/c0t1d0s1

So how can I recognize from this output how many disks there are in the system?

Thank you

There are at least two disks on your system, c0t0d0 and c0t1d0.

Please explain why

iostat -En|awk '/^c[0-9]/{printf("\n%3d : ",++d)}{gsub("  *"," ");gsub("[A-Za-z ][A-Za-z ]*: 0 ","");printf("%s ",$0)}END{printf("\n")}'

doesn't answer your question ?

Yes, it does answer my question. Sorry, I was refering to /dev/hd* /dev/sd* command.
iostat -En works perfectly. Thank you.

BTW, is c0t0d0 and c0t1d0 this number tx.... indicator how many disks there is in the system?

Not really. There is a controller number cx, a SCSI target number ty and a disk number dz. Each different combination of x,y and z denote a different disk.