My Favorites

Close

Please to see your favorites.

  • Bookmark
  • Email Document
  • Printer Friendly
  • Favorite
  • Rating:

udev matching does not work

This document (3235532) is provided subject to the disclaimer at the end of this document.

Environment

Novell SUSE Linux Enterprise Server 10

Novell Open Enterprise Server 2 (OES2)
Novell SUSE Linux Enterprise Desktop 10
Novell Linux Desktop 9

Host is logged in to one or more iSCSI targets.

Situation

Multiple iSCSI-based devices are connected to the host and since the order of the connection establishment to each of the targets their /dev/sd? assignment may vary, eg. /dev/sdb is not always linked the same iSCSI target.

Goal
We want to create rules that set up a symlink based on e.g.only a part of the iSCSI target name to avoid awfully long entries in /etc/fstab, which must be updated if the iSCSI target is being renamed/recreated/moved.

To achieve this the following rules are constructed :
# Match on *ivol1* in ID_PATH and log to syslog
KERNEL=="sd*[!0-9]", ENV{ID_VENDOR}=="IET", ENV{ID_PATH}=="*ivol1*", RUN+="/bin/logger Creating symlink /dev/disk/iscsi/ivol1 for $env{ID_PATH}", SYMLINK+="disk/iscsi/ivol1"
# Match on *ivol2* in ID_PATH and log to syslog
KERNEL=="sd*[!0-9]", ENV{ID_VENDOR}=="IET", ENV{ID_PATH}=="*ivol2*", RUN+="/bin/logger Creating symlink /dev/disk/iscsi/ivol2 for $env{ID_PATH}", SYMLINK+="disk/iscsi/ivol2"
These will persistently enable us to eg. mount an iSCSI target that has the string "ivol1” in its name from/dev/disk/iscsi/ivol1 so that the entry in /etc/fstab could look like
/dev/disk/iscsi/ivol1 /mnt/iscsi/ivol1 reiserfs defaults 0 0
instead of having to specify the full path like this
/dev/disk/by-path/ip-192.168.0.111:3260-iscsi-ivol1.t2mob.nts.com:e8ac1d4d-47f3-4dd3-b9a5-ff1e01f61618-lun-0


Symptom
The match on ENV{ID_PATH}=="*whatever*" does not work at all.
It is possible to display the contents of certain udev environment variables in a udev rule in/etc/udev/rules.d/60-persistent-storage.rules, but at the same time it is not possible to perform a match on them.
While it is possible to match onENV{ID_VENDOR}, matches on eg. ENV{ID_PATH} or ENV{ID_FS_UUID} do not work.
What might be even more confusing is that the variables really seem to be populated if tested with a rule like this, which will display its output in syslog :
KERNEL=="sd*", ENV{ID_VENDOR}=="IET", RUN+="/bin/logger ID_VENDOR contains $env{ID_VENDOR} , ID_FS_UUID contains $env{ID_FS_UUID} and ID_PATH is $env{ID_PATH}"

Resolution

Cause

The root cause is incorrect order of rules.

The reason for this to fail is usually that the rule is executed before the calls to path_id and vol_id in /etc/udev/rules.d/60-persistent-storage.rules. The confusion about that you are able to display the contents of the variables in the RUN key, is that RUN keys are "postprocess" instructions which will be evaluated _after_ all rules are run, so they work in the debugging rule, while the variables are not yet initialized at the time the SYMLINK assignment key is executed.

Resolution

Since the rule files in/etc/udev/rules.d/are executed in alphabetical order, the simplest solution is to move the rules out of /etc/udev/rules.d/60-persistent-storage.rules and create a new file, which is executed later, e.g. by naming it61-persistent-iscsi.rules.
Alternatively the rules can be moved to the bottom of 60-persistent-storage.rules - just above the last line containing "LABEL="persistent_storage_end"".

Disclaimer

This Support Knowledgebase provides a valuable tool for NetIQ/Novell/SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:3235532
  • Creation Date:15-JAN-08
  • Modified Date:27-APR-12
    • SUSESUSE Linux Enterprise Desktop
      SUSE Linux Enterprise Server

Did this document solve your problem? Provide Feedback

< Back to Support Search

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.


SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center