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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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 |
| |||
| 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 |
| |||
| 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 |
| |||
| 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 |
| |||
| 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 |
| |||
| 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 |
| ||||
| 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 |