In our previous article, we have used ASMLIB to create consistent disks for Oracle ASM. But there are some Linux distros for which ASMLIB kernel drivers are not available. Therefore, we have to use udev (Linux Device Manager) to create the consistent disks for Oracle ASM.
In this article, we will show you how to create udev rules for Oracle ASM.
Table of Contents
Linux Server Specification
We have configured a Linux virtual machine with some unused space. We will use this unused space to create consistents disks.
CPU | 2.4 Ghz (Single Core) |
Memory | 1 GB |
Operating System | CentOS 6.7 |
Storage: | |
/dev/sda | 20 GB for swap and Linux |
/dev/sdb | 2 GB for asm-disk1 |
/dev/sdc | 2 GB for asm-disk2 |
/dev/sdd | 2 GB for asm-disk3 |
Configure udev rules for Oracle ASM
This method does not work with disk partitions, therefore, I have added 3 equally-sized virtual disks to our virtual machine.
# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b53f3
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdd: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_testserver-lv_root: 18.9 GB, 18865979392 bytes
255 heads, 63 sectors/track, 2293 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_testserver-lv_swap: 2080 MB, 2080374784 bytes
255 heads, 63 sectors/track, 252 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Create partitions in all 3 disks.
# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x76935e66.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
Using default value 261
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x55ffa8e2.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
Using default value 261
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xb2a8a4c8.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
Using default value 261
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Load updated block device partition tables as follows:
# /sbin/partprobe /dev/sdb1
# /sbin/partprobe /dev/sdc1
# /sbin/partprobe /dev/sdd1
Use scsi_id to obtain unique SCSI ID of each disk.
# /sbin/scsi_id -g -u -d /dev/sdb
36000c291381e5b565048efead9df75e7
# /sbin/scsi_id -g -u -d /dev/sdc
36000c2973befa14808a2717562022211
# /sbin/scsi_id -g -u -d /dev/sdd
36000c29e5e39da397c14ad10ed2dd557
If you are using virtual machine then above statements may return NULL, because, by default VMWare does not provide SCSI ID to disks. To enable this feature shutdown the VM and add following line in .vmx file of your virtual machine. After that restart VM and try above commands again.
disk.EnableUUID = "TRUE"
Create OS user and groups for Oracle ASM disk owner.
# groupadd -g 601 oinstall
# groupadd -g 602 dba
# groupadd -g 603 oper
# groupadd -g 604 asmadmin
# groupadd -g 605 asmoper
# groupadd -g 606 asmdba
# useradd -u 601 -g oinstall -G asmadmin,asmdba,asmoper grid
# passwd grid
Changing password for user grid.
New password:
BAD PASSWORD: it is WAY too short
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
Create udev rules by using the UUIDs of the disks to create ASM disks.
# echo options=-g >> /etc/scsi_id.config
# cat >> /etc/udev/rules.d/99-oracle-asmdevices.rules << EOF
> KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="36000c291381e5b565048efead9df75e7”,NAME="asm-disk1", OWNER="grid", GROUP="asmadmin", MODE="0660"
> KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="36000c2973befa14808a2717562022211", NAME="asm-disk2", OWNER="grid", GROUP="asmadmin", MODE="0660"
> KERNEL=="sd?1", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -d /dev/$parent", RESULT=="36000c29e5e39da397c14ad10ed2dd557", NAME="asm-disk3", OWNER="grid", GROUP="asmadmin", MODE="0660
> EOF
Test udev rules with following commands.
# udevadm test /block/sdb/sdb1
run_command: calling: test
udevadm_test: version 147
This program is for debugging only, it does not run any program,
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
parse_file: reading '/lib/udev/rules.d/10-console.rules' as rules file
parse_file: reading '/lib/udev/rules.d/10-dm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/11-dm-lvm.rules' as rules file
parse_file: reading '/lib/udev/rules.d/13-dm-disk.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-isdn.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-multipath.rules' as rules file
parse_file: reading '/lib/udev/rules.d/40-redhat.rules' as rules file
parse_file: reading '/lib/udev/rules.d/42-qemu-usb.rules' as rules file
parse_file: reading '/lib/udev/rules.d/50-firmware.rules' as rules file
parse_file: reading '/lib/udev/rules.d/50-udev-default.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-cdrom_id.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-net.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-alsa.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-input.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-serial.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-storage-tape.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-storage.rules' as rules file
parse_file: reading '/lib/udev/rules.d/60-persistent-v4l.rules' as rules file
parse_file: reading '/etc/udev/rules.d/60-raw.rules' as rules file
parse_file: reading '/lib/udev/rules.d/61-mobile-action.rules' as rules file
parse_file: reading '/lib/udev/rules.d/61-option-modem-modeswitch.rules' as rules file
parse_file: reading '/lib/udev/rules.d/61-persistent-storage-edd.rules' as rules file
parse_file: reading '/lib/udev/rules.d/64-device-mapper.rules' as rules file
parse_file: reading '/lib/udev/rules.d/64-md-raid.rules' as rules file
parse_file: reading '/lib/udev/rules.d/69-dm-lvm-metad.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-acl.rules' as rules file
parse_file: reading '/lib/udev/rules.d/70-hid2hci.rules' as rules file
parse_file: reading '/etc/udev/rules.d/70-persistent-cd.rules' as rules file
parse_file: reading '/etc/udev/rules.d/70-persistent-net.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-cd-aliases-generator.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-net-description.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-persistent-net-generator.rules' as rules file
parse_file: reading '/lib/udev/rules.d/75-tty-description.rules' as rules file
parse_file: reading '/lib/udev/rules.d/78-sound-card.rules' as rules file
parse_file: reading '/lib/udev/rules.d/79-fstab_import.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-drivers.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-iosched.rules' as rules file
parse_file: reading '/lib/udev/rules.d/80-mpath-iosched.rules' as rules file
parse_file: reading '/lib/udev/rules.d/88-clock.rules' as rules file
parse_file: reading '/etc/udev/rules.d/91-drm-modeset.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-dm-notify.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-keyboard-force-release.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-keymap.rules' as rules file
parse_file: reading '/lib/udev/rules.d/95-udev-late.rules' as rules file
parse_file: reading '/etc/udev/rules.d/99-oracle-asmdevices.rules' as rules file
parse_file: reading '/dev/.udev/rules.d/99-root.rules' as rules file
parse_file: reading '/etc/udev/rules.d/99-vmware-scsi-udev.rules' as rules file
udev_rules_new: rules use 28908 bytes tokens (2409 * 12 bytes), 17584 bytes buffer
udev_rules_new: temporary index used 17920 bytes (896 * 20 bytes)
udev_device_new_from_syspath: device 0x7f69aded4b30 has devpath '/devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0/block/sdb/sdb1'
udev_device_new_from_syspath: device 0x7f69adedc470 has devpath '/devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0/block/sdb/sdb1'
udev_device_read_db: device 0x7f69adedc470 filled with db file data
udev_rules_apply_to_event: RUN 'socket:/org/kernel/dm/multipath_event' /lib/udev/rules.d/40-multipath.rules:16
udev_rules_apply_to_event: LINK 'block/8:17' /lib/udev/rules.d/50-udev-default.rules:3
udev_rules_apply_to_event: GROUP 6 /lib/udev/rules.d/50-udev-default.rules:76
udev_device_new_from_syspath: device 0x7f69adec25c0 has devpath '/devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0/block/sdb'
udev_device_read_db: device 0x7f69adec25c0 filled with db file data
udev_rules_apply_to_event: LINK 'disk/by-id/scsi-36000c291381e5b565048efead9df75e7-part1' /lib/udev/rules.d/60-persistent-storage.rules:44
udev_device_new_from_syspath: device 0x7f69ade9d8a0 has devpath '/devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0'
udev_device_new_from_syspath: device 0x7f69ade9da10 has devpath '/devices/pci0000:00/0000:00:10.0/host2/target2:0:1'
udev_device_new_from_syspath: device 0x7f69ade9dbe0 has devpath '/devices/pci0000:00/0000:00:10.0/host2'
udev_device_new_from_syspath: device 0x7f69adecd3a0 has devpath '/devices/pci0000:00/0000:00:10.0'
udev_device_new_from_syspath: device 0x7f69adecd650 has devpath '/devices/pci0000:00'
udev_rules_apply_to_event: LINK 'disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1' /lib/udev/rules.d/60-persistent-storage.rules:62
udev_rules_apply_to_event: IMPORT '/sbin/blkid -o udev -p /dev/block/8:17' /lib/udev/rules.d/60-persistent-storage.rules:76
util_run_program: '/sbin/blkid -o udev -p /dev/block/8:17' started
util_run_program: '/sbin/blkid -o udev -p /dev/block/8:17' returned with exitcode 2
udev_rules_apply_to_event: LINK 'disk/by-id/wwn-0x6000c291381e5b565048efead9df75e7-part1' /lib/udev/rules.d/60-persistent-storage.rules:91
udev_rules_apply_to_event: PROGRAM '/sbin/scsi_id -g -u -d /dev/sdb' /etc/udev/rules.d/99-oracle-asmdevices.rules:1
util_run_program: '/sbin/scsi_id -g -u -d /dev/sdb' started
util_run_program: '/sbin/scsi_id' (stdout) '36000c291381e5b565048efead9df75e7'
util_run_program: '/sbin/scsi_id -g -u -d /dev/sdb' returned with exitcode 0
udev_rules_apply_to_event: OWNER 601 /etc/udev/rules.d/99-oracle-asmdevices.rules:1
udev_rules_apply_to_event: GROUP 604 /etc/udev/rules.d/99-oracle-asmdevices.rules:1
udev_rules_apply_to_event: MODE 0660 /etc/udev/rules.d/99-oracle-asmdevices.rules:1
udev_rules_apply_to_event: NAME 'asm-disk1' /etc/udev/rules.d/99-oracle-asmdevices.rules:1
udev_rules_apply_to_event: PROGRAM '/sbin/scsi_id -g -u -d /dev/sdb' /etc/udev/rules.d/99-oracle-asmdevices.rules:2
util_run_program: '/sbin/scsi_id -g -u -d /dev/sdb' started
util_run_program: '/sbin/scsi_id' (stdout) '36000c291381e5b565048efead9df75e7'
util_run_program: '/sbin/scsi_id -g -u -d /dev/sdb' returned with exitcode 0
udev_rules_apply_to_event: PROGRAM '/sbin/scsi_id -g -u -d /dev/sdb' /etc/udev/rules.d/99-oracle-asmdevices.rules:3
util_run_program: '/sbin/scsi_id -g -u -d /dev/sdb' started
util_run_program: '/sbin/scsi_id' (stdout) '36000c291381e5b565048efead9df75e7'
util_run_program: '/sbin/scsi_id -g -u -d /dev/sdb' returned with exitcode 0
udev_rules_apply_to_event: RUN '/bin/sh -c 'echo 180 >/sys$DEVPATH/timeout'' /etc/udev/rules.d/99-vmware-scsi-udev.rules:8
udev_device_update_db: created db file for '/devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0/block/sdb/sdb1' in '/dev/.udev/db/block:sdb1'
udev_node_add: creating device node '/dev/asm-disk1', devnum=8:17, mode=0660, uid=601, gid=604
udev_node_mknod: preserve file '/dev/asm-disk1', because it has correct dev_t
udev_node_mknod: preserve permissions /dev/asm-disk1, 060660, uid=601, gid=604
node_symlink: preserve already existing symlink '/dev/block/8:17' to '../asm-disk1'
link_find_prioritized: found '/sys/devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0/block/sdb/sdb1' claiming '/dev/.udev/links/diskx2fby-idx2fscsi-36000c291381e5b565048efead9df75e7-part1'
link_update: creating link '/dev/disk/by-id/scsi-36000c291381e5b565048efead9df75e7-part1' to '/dev/asm-disk1'
node_symlink: preserve already existing symlink '/dev/disk/by-id/scsi-36000c291381e5b565048efead9df75e7-part1' to '../../asm-disk1'
link_find_prioritized: found '/sys/devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0/block/sdb/sdb1' claiming '/dev/.udev/links/diskx2fby-pathx2fpci-0000:00:10.0-scsi-0:0:1:0-part1'
link_update: creating link '/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1' to '/dev/asm-disk1'
node_symlink: preserve already existing symlink '/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1' to '../../asm-disk1'
link_find_prioritized: found '/sys/devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0/block/sdb/sdb1' claiming '/dev/.udev/links/diskx2fby-idx2fwwn-0x6000c291381e5b565048efead9df75e7-part1'
link_update: creating link '/dev/disk/by-id/wwn-0x6000c291381e5b565048efead9df75e7-part1' to '/dev/asm-disk1'
node_symlink: preserve already existing symlink '/dev/disk/by-id/wwn-0x6000c291381e5b565048efead9df75e7-part1' to '../../asm-disk1'
udevadm_test: UDEV_LOG=6
udevadm_test: DEVPATH=/devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0/block/sdb/sdb1
udevadm_test: MAJOR=8
udevadm_test: MINOR=17
udevadm_test: DEVNAME=/dev/asm-disk1
udevadm_test: DEVTYPE=partition
udevadm_test: ACTION=add
udevadm_test: SUBSYSTEM=block
udevadm_test: MPATH_SBIN_PATH=/sbin
udevadm_test: DEVLINKS=/dev/block/8:17 /dev/disk/by-id/scsi-36000c291381e5b565048efead9df75e7-part1 /dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:1:0-part1 /dev/disk/by-id/wwn-0x6000c291381e5b565048efead9df75e7-part1
udevadm_test: ID_SCSI=1
udevadm_test: ID_VENDOR=VMware_
udevadm_test: ID_VENDOR_ENC=VMwarex2cx20
udevadm_test: ID_MODEL=VMware_Virtual_S
udevadm_test: ID_MODEL_ENC=VMwarex20Virtualx20S
udevadm_test: ID_REVISION=1.0
udevadm_test: ID_TYPE=disk
udevadm_test: ID_SERIAL_RAW=36000c291381e5b565048efead9df75e7
udevadm_test: ID_SERIAL=36000c291381e5b565048efead9df75e7
udevadm_test: ID_SERIAL_SHORT=6000c291381e5b565048efead9df75e7
udevadm_test: ID_WWN=0x6000c291381e5b56
udevadm_test: ID_WWN_VENDOR_EXTENSION=0x5048efead9df75e7
udevadm_test: ID_WWN_WITH_EXTENSION=0x6000c291381e5b565048efead9df75e7
udevadm_test: ID_SCSI_SERIAL=6000c291381e5b565048efead9df75e7
udevadm_test: ID_BUS=scsi
udevadm_test: ID_PATH=pci-0000:00:10.0-scsi-0:0:1:0
udevadm_test: ID_PART_TABLE_TYPE=dos
udevadm_test: LVM_SBIN_PATH=/sbin
udevadm_test: run: 'socket:/org/kernel/dm/multipath_event'
udevadm_test: run: '/bin/sh -c 'echo 180 >/sys$DEVPATH/timeout''
Repeat the above comand for /dev/sdc1 and /dev/sdd1.
# udevadm test /block/sdb/sdc1 # udevadm test /block/sdb/sdd1
Restart udev.
# udevadm control --reload-rules
# /sbin/start_udev
Starting udev: [ OK ]
Check our ASM disks.
# ls -al /dev/asm-disk*
brw-rw----. 1 grid asmadmin 8, 17 Apr 11 22:10 /dev/asm-disk1
brw-rw----. 1 grid asmadmin 8, 33 Apr 11 22:05 /dev/asm-disk2
brw-rw----. 1 grid asmadmin 8, 49 Apr 11 22:05 /dev/asm-disk3
udev configurations has been completed. Now we have 3 disks that will remain consistent during system restarts and can be used as Oracle ASM Disks.
Read Also: How to install Oracle 12c on Linux
If you are new to Linux and facing difficulty in working at Linux Bash prompt. We recommend that, you should read The Linux Command Line, 2nd Edition: A Complete Introduction by William Shotts.
Conclusion – udev rules for Oracle ASM
We have create UDEV rules for Oracle ASM in this article.