Creating ASM devices on AIX

I thought of sharing few tips on creating ASM devices on AIX which I will be helpful to Oracle DBA’s. Suppose SysAdmin gives you list of Serial numbers for LUN instead of device Name

pcmpath query device
DEV#:  33  DEVICE NAME: hdisk33  TYPE: 2107900  ALGORITHM:  Load Balance
SERIAL: 75DM011<span style="color: #ff0000;"><strong>1101</strong></span>
===========================================================================
Path#      Adapter/Path Name          State     Mode     Select     Errors
    0           fscsi0/path0          CLOSE   NORMAL          9          0
    1           fscsi1/path1          CLOSE   NORMAL          8          0

In case there are lot many disks, then it could be a tiring task of running above command and finding each device. You can use below code which will list name ofย  devices and size (In MB) of disk.

for i in 1000 1100    1018    1118    1030    1130    104C    114C    1068    1168    1080    1180
do
j=`pcmpath query device|grep -p $i"$"|grep DEVICE|awk -F ":" '{print }'|awk '{print }`
k=`bootinfo -s $j`
echo $i $j $k
done

This would return following output

1000 hdisk4 65536
1100 hdisk10 65536
1018 hdisk5 65536
1118 hdisk11 65536
1030 hdisk6 65536
1130 hdisk12 65536
104C hdisk7 65536
114C hdisk13 65536
1068 hdisk8 65536
1168 hdisk14 65536
1080 hdisk9 65536
1180 hdisk15 65536

Now if you need to create new device name, you need to use mknod command and pass on major and minor numbers. Following code can be used to perform same

#export m=0
 # for i in hdisk4  hdisk10 hdisk5  hdisk11 hdisk6  hdisk12 hdisk7  hdisk13 hdisk8  hdisk14 hdisk9  hdisk15
 do
 j=`ls -la /dev/$i |awk '{print }'|awk -F "," '{print }'`
  k=`ls -la /dev/$i |awk '{print }'`
 m=`expr $m + 1` ;echo "mknod /dev/asm_disk"$m "c "$j $k
 done

 mknod /dev/asm_disk1 c 21 4
 mknod /dev/asm_disk2 c 21 12
 mknod /dev/asm_disk3 c 21 13
 mknod /dev/asm_disk4 c 21 15
 mknod /dev/asm_disk5 c 21 5
 mknod /dev/asm_disk6 c 21 6
 mknod /dev/asm_disk7 c 21 8
 mknod /dev/asm_disk8 c 21 7
 mknod /dev/asm_disk9 c 21 14
 mknod /dev/asm_disk10 c 21 10
 mknod /dev/asm_disk11 c 21 9
 mknod /dev/asm_disk12 c 21 11

Now you can change the ownership to oracle:dba and permission to 660. I have 12 disks , so using list of 12 variables. In case you have more disks , then you can add more variables

# for i in 1 2 3 4 5 6 7 8 9 10 11 12
do
chown oracle:dba /dev/asm_disk$i
chmod 660 /dev/asm_disk$i
done

crw-rw----    1 oracle   dba          21, 11 Jan 28 17:10 /dev/asm_disk12
crw-rw----    1 oracle   dba          21,  9 Jan 28 17:10 /dev/asm_disk11
crw-rw----    1 oracle   dba          21, 10 Jan 28 17:10 /dev/asm_disk10
crw-rw----    1 oracle   dba          21, 14 Jan 28 17:04 /dev/asm_disk9
crw-rw----    1 oracle   dba          21,  7 Jan 28 17:04 /dev/asm_disk8
crw-rw----    1 oracle   dba          21,  8 Jan 28 17:04 /dev/asm_disk7
crw-rw----    1 oracle   dba          21,  6 Jan 28 17:04 /dev/asm_disk6
crw-rw----    1 oracle   dba          21,  5 Jan 28 17:04 /dev/asm_disk5
crw-rw----    1 oracle   dba          21, 15 Jan 28 17:04 /dev/asm_disk4
crw-rw----    1 oracle   dba          21, 13 Jan 28 17:04 /dev/asm_disk3
crw-rw----    1 oracle   dba          21, 12 Jan 28 17:04 /dev/asm_disk2
crw-rw----    1 oracle   dba          21,  4 Jan 28 17:04 /dev/asm_disk1

In case you need to use same logic for creating OCR and Voting disks on RAC system, replace /dev/asm with /dev/ocr or /dev/voting . I hope this would save some time and also prevent errors ๐Ÿ™‚

In case you have disks in ordered number,say 53 to 62 then you can also use for loop as below.

#bash
bash-3.00#
#export m=0
#for ((i=53;i<=62;i++))
do
 j=`ls -la /dev/hdisk$i |awk '{print }'|awk -F "," '{print }'`
  k=`ls -la /dev/hdisk$i |awk '{print }'`
   m=`expr $m + 1` ;echo "mknod /dev/asm_disk"$m "c "$j $k
 done
#for ((i=1;i<=10;i++))
do
chown oracle:dba /dev/asm_disk$i
chmod 660 /dev/asm_disk$i
done

I would suggest anyone using the scripts to first check in a test environment.

Tags: , , , , ,

7 thoughts on “Creating ASM devices on AIX”

  • Instead of running the mknod, why not just do an ln of the rdisk:

    (these two should be the same)
    mknod /dev/asm_disk1 c 21 4
    ln rhdisk4 asm_disk1

    If you can find a way to increment the disk # easily, you would be golden and it would save a few lines

    • John,

      You can use soft links but oracle recommend's using mknod to create link. You can use following code to increment disk#


      for i in 1960 20CD 20CE 20CF 21CD 21CE
      do
      j=`pcmpath query device|grep -p $i"$"|grep DEVICE|awk -F ":" '{print $3}'|awk '{print $1}`
      k=`bootinfo -s $j`
      a=`ls -la /dev/$j |awk '{print $5}'|awk -F "," '{print $1}'`
      b=`ls -la /dev/$j |awk '{print $6}'`
      b=`echo $b |awk '{x=$0+0; print x}'`
      if [ b -le 1 ]
      then
      b=`ls -la /dev/$j |awk '{print $5}'|awk -F "," '{print $2}'`
      fi
      if [ m -le 8 ]
      then
      m=`expr $m + 1` ;echo "mknod /dev/asm_disk0"$m "c "$a $b
      else
      m=`expr $m + 1` ;echo "mknod /dev/asm_disk"$m "c "$a $b
      fi
      done

      -Amit

  • Thanks to your instructions, I was able to get this working once before. However, I am trying to do it again and I’m running into trouble. When I try to create the ASM disk group during the grid infrastructure installation, the disks do not show up. In my case, the disks I’m trying to add are EMC powerpath disks. Any idea what could cause them to not show up?

  • Hi Lucas,

    If you have set set asm_diskstring parameter to correct value i.e, something like /dev/rhd* (in case of emcpowerpath) the disks should be visible to you.

    If still the disks are not getting shown please check Metalink note 1174604.1 “ASM Is Not Detecting EMC PowerPath Raw Devices Or Regular Raw Devices On AIX” as there could be some permissions issue.

    Regards,
    Saurabh Sood

  • Thanks for the sharp article.
    It would be to name as /dev/asmdisk_data_nn for DATA, /dev/asmdisk_ocr_nn for OCR/Voting (12c), and /dev/asmdisk_fra_nn for FRA and then asm_diskstring could be like “/dev/asmdisk*” for ALL disks to be discovered by ASM. It is good way to do for Oracle Grid 12c where ocr/voting disks could be in/part of ASM Disk groups.
    thanks again.
    Natarajan

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.