Using UDEV for ASM

In Linux systems, device names such as sdb or dm-1 may change after a reboot, which can cause ASM disks to become unrecognized.
To prevent this issue, persistent identifiers must be used, and a fixed name for the partition should be created using udev.

Oracle documentation and specialized technical articles strongly emphasize using a unique disk or partition identifier. These identifiers remain unchanged after every reboot and are used as keys in udev rules.
It is also recommended to use the SYMLINK attribute instead of the NAME key when creating a persistent device name, because in newer versions of Oracle Linux the NAME key does not work properly.


1 – Checking Disk Status and Creating a Partition

First, check the disks and partitions using the lsblk command.
In the example below, the system disk (sda) contains system and LVM partitions and must not be used for ASM.
The second disk (sdb) has a capacity of 20 GB and is empty, making it suitable for ASM.

[root@vahiddb ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  100G  0 disk
├─sda1   8:1    0    1G  0 part /boot/efi
├─sda2   8:2    0   40G  0 part /u01
├─sda3   8:3    0   20G  0 part /
├─sda4   8:4    0   15G  0 part /var
├─sda5   8:5    0    5G  0 part /home
├─sda6   8:6    0    4G  0 part [SWAP]
└─sda7   8:7    0   15G  0 part /tmp
sdb      8:16   0   20G  0 disk
sr0     11:0    1 13.2G  0 rom

2 – Creating a Partition on the Disk

If the target disk is not partitioned, create a new partition using fdisk or parted.

[root@vahiddb ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xcf143bac.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039):

Created a new partition 1 of type 'Linux' and of size 20 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

3 – Obtaining the Persistent Partition Identifier

To make the disk name persistent in udev, we must use the unique partition identifier.
Technical references emphasize that partition UUID should be used in udev rules instead of filesystem UUIDs or device node names.
This identifier appears in the udevadm output as ID_PART_ENTRY_UUID.

Use the following command to find the partition identifier (in this example, for sdb1):

[root@dc2 ~]# udevadm info --query=all --name=/dev/sdb1 | egrep 'ID_PART_ENTRY_UUID|ID_PART_TABLE_TYPE'
E: ID_PART_TABLE_TYPE=dos
E: ID_PART_ENTRY_UUID=26772855-01

The value of ID_PART_ENTRY_UUID will be different for your partition.
Partitions using an MBR (DOS) partition table typically have a UUID that includes the partition number (for example, -01).
When using GPT, a full UUID is usually displayed.

If needed, you can view the same value using blkid:

blkid /dev/sdb1
/dev/sdb1: PARTUUID="26772855-01"

4 – Creating a UDEV Rule Using the Partition Identifier

To create a persistent device name, you must create a udev rules file under /etc/udev/rules.d.
Various sources recommend storing udev rules in a file with a high numeric prefix such as 99- to ensure proper execution order.
It is also recommended to use SYMLINK instead of NAME to create a stable link under /dev.

Create the following directory on the operating system:

mkdir /dev/oracleasm

Create the file /etc/udev/rules.d/99-oracle-disk.rules using a text editor and add the following content
(adjust the UUID value and symlink name according to your own partition):

ACTION=="add|change", KERNEL=="sd*", \
ENV{ID_PART_ENTRY_UUID}=="26772855-01", \
SYMLINK+="oracleasm/data01", OWNER="oracle", GROUP="asmadmin", MODE="0660"

Explanation of the rule components:

  • ACTION: In this example, both add and change events are handled so the rule is applied when the disk is added or modified.

  • KERNEL: Filters all devices matching sd*.

  • ENV{ID_PART_ENTRY_UUID}: The target partition UUID; this key uniquely identifies the partition.

  • SYMLINK: The name to be created for the partition; in this example, /dev/oracleasm/data01.
    Using SYMLINK instead of NAME is recommended in Oracle Linux 7 and 8.

  • OWNER / GROUP / MODE: Sets ownership and permissions for the oracle user and asmadmin group.


5 – Reloading and Applying UDEV Rules

To apply the new rules, reload and trigger udev:

udevadm control --reload-rules
udevadm trigger

6 – Verifying the Result and Using It in ASM

After running the above commands, a new link should be created under /dev:

[root@dc2 ~]# ls -l /dev/data01
lrwxrwxrwx. 1 root root 4 Nov 19 06:24 /dev/data01 -> sdb1

Video Link

YouTube video link for this section in persian