Unix Technical Forum

disk probing on solaris 10 6/06

This is a discussion on disk probing on solaris 10 6/06 within the Sun Solaris Administration forums, part of the Solaris Operating System category; --> Is there a way to programmatically list all the hard disk devices attached to a solaris box? "format" command ...


Go Back   Unix Technical Forum > Unix Operating Systems > Solaris Operating System > Sun Solaris Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-16-2008, 09:59 AM
Anoop
 
Posts: n/a
Default disk probing on solaris 10 6/06

Is there a way to programmatically list all the hard disk devices
attached to a solaris box?

"format" command doesn't help, as it requires user input or prior
knowledge of the existance of a particular disk.

What I'm looking for is something like the solaris equivalent of
/proc/partitions that's present on linux.

Any suggestions?

Thanks,
-anoop

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-16-2008, 09:59 AM
erforcella@gmail.com
 
Posts: n/a
Default Re: disk probing on solaris 10 6/06

Hi Anoop
format whit the option print and partiotions (P - P), shows all the
fisical partition in the disk.
I don't know what /proc/partitions in linux does.
But for example in solaris U can create a file called for example
ListPartiotions like this.

#more ListPartiotions
p
p

And try the format command with this option:

#format -d c0t0d0 < ListPartiotions

Assuming that c0t0d0 is your Disk.

If you want you can do a simply shell that do this for all disks that u
have!

-----------------------------------------
Ciao################
-----------------------------------------

Anoop ha scritto:

> Is there a way to programmatically list all the hard disk devices
> attached to a solaris box?
>
> "format" command doesn't help, as it requires user input or prior
> knowledge of the existance of a particular disk.
>
> What I'm looking for is something like the solaris equivalent of
> /proc/partitions that's present on linux.
>
> Any suggestions?
>
> Thanks,
> -anoop


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-16-2008, 09:59 AM
Anoop
 
Posts: n/a
Default Re: disk probing on solaris 10 6/06

Thanks. But what I really need is a way to find out what disks are
already available on the machine. This means I don't know that c0t0d0
is a hard disk, and I need to find out.

How would I do that in a non-interactive more?

On linux, /proc/partitions is just a file which lists all the
partitions of the root device (including the 0th partition itself). For
example, if Linux is installed on the first scsi disk, then
/proc/partitions will contain


major minor #blocks name

8 0 78150744 sda
8 1 8193118 sda1
8 2 4096575 sda2
8 3 1020127 sda3
8 4 1 sda4
8 5 64838308 sda5

This means that my root disk is the first entry sda (ie /dev/sda). How
do I get similar information on solaris, either by running a command or
looking into a file?

Thanks,
-anoop

erforcella@gmail.com wrote:
> Hi Anoop
> format whit the option print and partiotions (P - P), shows all the
> fisical partition in the disk.
> I don't know what /proc/partitions in linux does.
> But for example in solaris U can create a file called for example
> ListPartiotions like this.
>
> #more ListPartiotions
> p
> p
>
> And try the format command with this option:
>
> #format -d c0t0d0 < ListPartiotions
>
> Assuming that c0t0d0 is your Disk.
>
> If you want you can do a simply shell that do this for all disks that u
> have!
>
> -----------------------------------------
> Ciao################
> -----------------------------------------
>
> Anoop ha scritto:
>
> > Is there a way to programmatically list all the hard disk devices
> > attached to a solaris box?
> >
> > "format" command doesn't help, as it requires user input or prior
> > knowledge of the existance of a particular disk.
> >
> > What I'm looking for is something like the solaris equivalent of
> > /proc/partitions that's present on linux.
> >
> > Any suggestions?
> >
> > Thanks,
> > -anoop


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-16-2008, 09:59 AM
Daniel Rock
 
Posts: n/a
Default Re: disk probing on solaris 10 6/06

Anoop <anoop.rajendra@gmail.com> wrote:
> This means that my root disk is the first entry sda (ie /dev/sda). How
> do I get similar information on solaris, either by running a command or
> looking into a file?


[Please don't top post. Trim down the message you are answering to the
relevant information]

You can either call "format >disklist </dev/null" and count the number
of disk lines, like:

disklist=$(format </dev/null | nawk '/[0-9]+\. c[0-9]/ { print $2"s2"}')


Or call prtvtoc for every entry you find in /dev/rdsk/*s2. If prtvtoc
returns an error there was once a disk at this address but has been gone
(to clean-up call "devfsadm -C"), like:

disklist=""
for disk in /dev/rdsk/*s2; do
prtvtoc ${disk} >/dev/null 2>&1 && disklist="${disklist} ${disk}"
done


--
Daniel
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-16-2008, 09:59 AM
erforcella@gmail.com
 
Posts: n/a
Default Re: disk probing on solaris 10 6/06

Hi
you can know the disks available in the solaris box for example with:
# iostat -En

# df -k
U can see where the root is mounted

or in the /etc/mnttab file

Hope this help!

##########
Ciao
##########



Anoop ha scritto:

> Thanks. But what I really need is a way to find out what disks are
> already available on the machine. This means I don't know that c0t0d0
> is a hard disk, and I need to find out.
>
> How would I do that in a non-interactive more?
>
> On linux, /proc/partitions is just a file which lists all the
> partitions of the root device (including the 0th partition itself). For
> example, if Linux is installed on the first scsi disk, then
> /proc/partitions will contain
>
>
> major minor #blocks name
>
> 8 0 78150744 sda
> 8 1 8193118 sda1
> 8 2 4096575 sda2
> 8 3 1020127 sda3
> 8 4 1 sda4
> 8 5 64838308 sda5
>
> This means that my root disk is the first entry sda (ie /dev/sda). How
> do I get similar information on solaris, either by running a command or
> looking into a file?
>
> Thanks,
> -anoop
>
> erforcella@gmail.com wrote:
> > Hi Anoop
> > format whit the option print and partiotions (P - P), shows all the
> > fisical partition in the disk.
> > I don't know what /proc/partitions in linux does.
> > But for example in solaris U can create a file called for example
> > ListPartiotions like this.
> >
> > #more ListPartiotions
> > p
> > p
> >
> > And try the format command with this option:
> >
> > #format -d c0t0d0 < ListPartiotions
> >
> > Assuming that c0t0d0 is your Disk.
> >
> > If you want you can do a simply shell that do this for all disks that u
> > have!
> >
> > -----------------------------------------
> > Ciao################
> > -----------------------------------------
> >
> > Anoop ha scritto:
> >
> > > Is there a way to programmatically list all the hard disk devices
> > > attached to a solaris box?
> > >
> > > "format" command doesn't help, as it requires user input or prior
> > > knowledge of the existance of a particular disk.
> > >
> > > What I'm looking for is something like the solaris equivalent of
> > > /proc/partitions that's present on linux.
> > >
> > > Any suggestions?
> > >
> > > Thanks,
> > > -anoop


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-16-2008, 09:59 AM
Anoop
 
Posts: n/a
Default Re: disk probing on solaris 10 6/06

Thanks, Daniel.
Daniel Rock wrote:
> Anoop <anoop.rajendra@gmail.com> wrote:
> > This means that my root disk is the first entry sda (ie /dev/sda). How
> > do I get similar information on solaris, either by running a command or
> > looking into a file?

>
> [Please don't top post. Trim down the message you are answering to the
> relevant information]
>
> You can either call "format >disklist </dev/null" and count the number
> of disk lines, like:
>
> disklist=$(format </dev/null | nawk '/[0-9]+\. c[0-9]/ { print $2"s2"}')


This is the exact command I was looking for. (Why the hell didn't I
think of /dev/null??? Aaargh!!!)

In any case, do you know if this command is available in a jumpstart
installation environment?


>
>
> Or call prtvtoc for every entry you find in /dev/rdsk/*s2. If prtvtoc
> returns an error there was once a disk at this address but has been gone
> (to clean-up call "devfsadm -C"), like:
>
> disklist=""
> for disk in /dev/rdsk/*s2; do
> prtvtoc ${disk} >/dev/null 2>&1 && disklist="${disklist} ${disk}"
> done
>
>
> --
> Daniel


Thanks,
Anoop

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-16-2008, 09:59 AM
Anoop
 
Posts: n/a
Default Re: disk probing on solaris 10 6/06

Also, I have another question

The command

disklist=$(format </dev/null | nawk '/[0-9]+\. c[0-9]/ { print $2}')

worked perfectly.

However, disklist is going to give me the list of all disks attached to
the system. I need only the root disk, or the disk that the machine
boots from? Is this always the first entry (or the zeroeth entry)?

Thanks,
Anoop

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-16-2008, 10:00 AM
Daniel Rock
 
Posts: n/a
Default Re: disk probing on solaris 10 6/06

Anoop <anoop.rajendra@gmail.com> wrote:
> Also, I have another question
>
> The command
>
> disklist=$(format </dev/null | nawk '/[0-9]+\. c[0-9]/ { print $2}')
>
> worked perfectly.
>
> However, disklist is going to give me the list of all disks attached to
> the system. I need only the root disk, or the disk that the machine
> boots from? Is this always the first entry (or the zeroeth entry)?


df -k / | awk '{ fs=$1 } END { print fs }'

(this will save you a "tail -1")

But beware: It doesn't have to be a "real" device. It could also be a SVM
device, a VxVM volume or (in the future) a ZFS.

--
Daniel

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:12 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com