Configuring Storage Device Path Persistence Using UDEV
Configuring Storage Device Path Persistence Using UDEV
For Oracle Automatic Storage Manager (ASM) to use disks, it needs to be able to identify the devices consistently and for them to have the correct ownership and permissions. In Linux you can use ASMLib to manage these tasks, but it is seen as an additional layer of complexity and has never really gained any popularity. Instead, many people use the Linux device manager "udev" to perform these tasks. This article presents a brief overview of setting up udev rules with respect to disks for use with ASM in Oracle 11g. The examples are all done using Oracle Linux 5, 6, 7 and 8 so they will be consistent with RHEL and CentOS 5, 6, 7 and 8.
- Identify the Disks (/sbin/scsi_id)
- Make SCSI Devices Trusted
- Create UDEV Rules File
- Load Updated Block Device Partitions (/sbin/partprobe)
- Test Rules (udevtest)
- Restart UDEV Service
- Check Ownership and Permissions
Identify the Disks (/sbin/scsi_id)
We are going to write device-specific rules, so we need to be able to identify each device consistently, irrespective of the order in which Linux discovers it.
To do this we are going to use the SCSI ID for each disk (not the partition), which we get using the scsi_id command. The "-s" option makes the paths relative to the "/sys" directory.
For Oracle Linux 5, use the following command.
/sbin/scsi_id -g -u -s /block/sdb |
The "-s" is not available in Oracle Linux 6, so you must use the following syntax.
/sbin/scsi_id -g -u -d /dev/sdb |
The location of the scsi_id command has changed in Oracle Linux 7 and 8, so you must use the following syntax.
/usr/lib/udev/scsi_id -g -u -d /dev/sdb |
Make SCSI Devices Trusted
Add the options=-g to the "/etc/scsi_id.config" file to configure SCSI devices as trusted. Create the file if it doesn't already exist.
cat >> /etc/scsi_id.config << EOF |
Create UDEV Rules File
Create the "/etc/udev/rules.d/99-oracle-asmdevices.rules" file.
The file should contain the following lines for Oracle Linux 5. The PROGRAM parameter must match the command you used to retrieve the SCSI ID, and the RESULT parameter must match the value returned from your disks.
for i in a b c |
The equivalent for Oracle Linux 6 is shown below.
for i in a b c |
The equivalent for Oracle Linux 7 and 8 is shown below.
for i in a b c |
Load Updated Block Device Partitions (/sbin/partprobe)
Load updated block device partition tables.
For OL5, OL6 and OL7
/sbin/partprobe /dev/sdb1 |
For OL8
/sbin/partx -u /dev/sbc1 |
Test Rules (udevtest)
Test the rules are working as expected.
For OL5
udevtest /block/sdb/sdb1 |
For OL6, OL7 and OL8
udevadm test /block/sdb/sdb1 |
The output from the first disk should look something like this.
udevtest /block/sdb/sdb1 |
Restart UDEV Service
Restart the UDEV service.
For OL5
/sbin/udevcontrol reload_rules |
For OL5 and OL6 : Not needed for OL7 and OL8
/sbin/start_udev |
For OL6, OL7 and OL8
/sbin/udevadm control --reload-rules |
Check Ownership and Permissions
Check the disks are now available with the "asm-disk*" alias and the correct ownership and permissions.
ls -al /dev/asm-disk* |
So the ASM_DISKSTRING initialization parameter in the ASM instance can be set to '/dev/asm-disk*' to identify the ASM disks.