How to add udev rules in Linux and trigger them without reboot ?

Today as part of practice I added udev rules for oracleasm disk in RHEL 6 64 bit VM hosted on VMware workstation.

I was trying to issued below command get the UUID for disk. But my command was not showing any output.

[root@Node2 rules.d]# scsi_id -g -u -d /dev/sdb

Above command was not showing any output. I google about it and found that I need to add the below line in
.vmx file of VM. I powered off the VM and added the below line in .vmx file of VM.

disk.EnableUUID = “TRUE”

After powering on the VM When I issued the same command was able to see the UUID

[root@Node2 rules.d]# scsi_id -g -u -d /dev/sdb
36000c29c87d186aa44b482d61c19844e

I went to below path to create rule for disk.

[root@Node2 rules.d]# pwd
/etc/udev/rules.d

I added below rule after create run file with name 99-oracle-asmdevices.rules

[root@Node2 rules.d]# cat 99-oracle-asmdevices.rules
KERNEL==”sd*”, SUBSYSTEM==”block”, ENV{DEVTYPE}==”disk”, ENV{ID_SERIAL}==”36000c29c87d186aa44b482d61c19844e”, NAME+=”oracleasm1″, OWNER=”oracle”, GROUP=”dba”, MODE=”0660″

We can issue below commands to reload the rules.

[root@Node2 rules.d]# udevadm control –reload-rules

[root@Node2 rules.d]# udevadm trigger

After that I was able to see the new name in drive tree.

[root@Node2 rules.d]# ls -lrt /dev/oracleasm1
brw-rw—-. 1 oracle dba 8, 16 Sep 23 00:52 /dev/oracleasm1

Advertisements

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 )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s