Raw Devices

Can you please modify my script. This script is not working

for i in /dev/sdf[0-9]
       do
                /bin/raw /dev/raw/`/bin/basename ${i}` ${i}
                /bin/sleep 2
                /bin/chown orasm:ordba /dev/raw/`/bin/basename ${i}`
                /bin/chmod 660 /dev/raw/`/bin/basename ${i}`
      done

When you say 'not working' what symptoms do you have?

What OS are you running? The needs of each flavour and version can be different.

Robin

I'm running this on Virtual RHEL 6.4 server. We are trying to create raw devices from a VMDK file to install Oracle ASM . I have made partitions on /dev/sdb ad trying to run this script.

[root@testvm init.d]# bash -x raw1
+ for i in '/dev/sdb[0-9]'
++ /bin/basename /dev/sdb1
+ /bin/raw /dev/raw/sdb1 /dev/sdb1
Usage:
  /bin/raw /dev/raw/rawN <major> <minor>
  /bin/raw /dev/raw/rawN /dev/<blockdev>
  /bin/raw -q /dev/raw/rawN
  /bin/raw -qa
+ sleep 2
++ /bin/basename /dev/sdb1
+ /bin/chown oraasm:oradba /dev/raw/sdb1
/bin/chown: cannot access `/dev/raw/sdb1': No such file or directory
++ /bin/basename /dev/sdb1
+ /bin/chmod 660 /dev/raw/sdb1
/bin/chmod: cannot access `/dev/raw/sdb1': No such file or directory
+ for i in '/dev/sdb[0-9]'
++ /bin/basename /dev/sdb2
+ /bin/raw /dev/raw/sdb2 /dev/sdb2
Usage:
  /bin/raw /dev/raw/rawN <major> <minor>
  /bin/raw /dev/raw/rawN /dev/<blockdev>
  /bin/raw -q /dev/raw/rawN
  /bin/raw -qa
+ sleep 2
++ /bin/basename /dev/sdb2
+ /bin/chown oraasm:oradba /dev/raw/sdb2
/bin/chown: cannot access `/dev/raw/sdb2': No such file or directory
++ /bin/basename /dev/sdb2
+ /bin/chmod 660 /dev/raw/sdb2
/bin/chmod: cannot access `/dev/raw/sdb2': No such file or directory
[root@testvm init.d]#

It's telling you what you're doing wrong:

+ /bin/raw /dev/raw/sdb1 /dev/sdb1
Usage:
  /bin/raw /dev/raw/rawN <major> <minor>
  /bin/raw /dev/raw/rawN /dev/<blockdev>
  /bin/raw -q /dev/raw/rawN
  /bin/raw -qa

You don't get a /dev/raw/sdb, you get /dev/raw/raw0, /dev/raw/raw1, etc, etc. (This is assuming you have /dev/raw at all.)

You might be able to get away with stripping the 'sdb' out of the filename to use /dev/raw/raw1 for /dev/sdb1, /dev/raw/raw2 for /dev/sdb2, etc, etc, assuming you aren't already using those raw devices for anything.

Thank you for your reply .I need to use the same script for all the servers which i build, My script should recognize the partitions and run the commands.

Well, do any of your other servers use raw devices for anything?

Nope, We are only using this for Oracle ASM.

Well, you could try what I suggested, stripping out everything but the partition number to associate it with the corresponding raw number.

Thank you, Appreciate your help .

Note that you should not use raw devices with Oracle ASM
(raw devices are desupported since Oracle 11.2 - see Announcement on using Raw devices with release 11.2 (Doc ID 754305.1)
and Raw Devices and Oracle - 20 Common Questions and Answers (Doc ID 37914.1)).

You just need shared disks with a single partition, see Configuring Storage for Oracle Automatic Storage Management.

1 Like