Skip to content

Which ASM Device is Which?

November 22, 2011

Did you happen to forget which raw device contains which Oracle ASM disk… perhaps you’ve reinstalled Oracle, or had a recent recovery event and lost your configuration. There may be an easy way to do this with an oracle script, but I’m not really a DBA. The ASM disk name is contained in the disk label, from the 136th byte (0x88) and terminated by NULL.

/********************************************************************
*
* asm-diskname.c
*
*********************************************************************
* Revision 1.0 19/11/2011 solidola
* Initial revision
*
*/

#include <stdio.h>
#include <fcntl.h>

int main (int argc, char **argv) {
  unsigned fp;
  char buffer[512];
  char diskname[20]="";
  int a,i;
  int offset = 0x88;
  /* the asm disk name seems to start at 0x88 and is
  terminated by NULL */

  fp = open(argv[1], O_RDONLY);
  if (fp == NULL ) {
    printf("Unable to open %s", argv[1]);
    return (1);
    }

  if (read(fp, buffer,512) 0 )
  diskname[i]=buffer[offset + i++];

  printf("%s\n",diskname);

  return (0);
  }
Advertisements

From → SysAdmin

Leave a Comment

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s

%d bloggers like this: