56-lvm.rules 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright (C) 2009 Red Hat, Inc. All rights reserved.
  2. #
  3. # This file is part of LVM2.
  4. # Udev rules for LVM.
  5. #
  6. # These rules create symlinks for LVM logical volumes in
  7. # /dev/VG directory (VG is an actual VG name). Some udev
  8. # environment variables are set (they can be used in later
  9. # rules as well):
  10. # DM_LV_NAME - logical volume name
  11. # DM_VG_NAME - volume group name
  12. # DM_LV_LAYER - logical volume layer (blank if not set)
  13. # "add" event is processed on coldplug only!
  14. ACTION!="add|change", GOTO="lvm_end"
  15. ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end"
  16. ENV{DM_UUID}!="LVM-?*", GOTO="lvm_end"
  17. # Use DM name and split it up into its VG/LV/layer constituents.
  18. IMPORT{program}="/sbin/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}"
  19. # DM_SUBSYSTEM_UDEV_FLAG0 is the 'NOSCAN' flag for LVM subsystem.
  20. # This flag is used to temporarily disable selected rules to prevent any
  21. # processing or scanning done on the LVM volume before LVM has any chance
  22. # to zero any stale metadata found within the LV data area. Such stale
  23. # metadata could cause false claim of the LV device, keeping it open etc.
  24. #
  25. # If the NOSCAN flag is present, backup selected existing flags used to
  26. # disable rules, then set them firmly so those selected rules are surely skipped.
  27. # Restore these flags once the NOSCAN flag is dropped (which is normally any
  28. # uevent that follows for this LV, even an artificially generated one).
  29. ENV{DM_SUBSYSTEM_UDEV_FLAG0}=="1", ENV{DM_NOSCAN}="1", ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="$env{DM_UDEV_DISABLE_OTHER_RULES_FLAG}", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
  30. ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", IMPORT{db}="DM_NOSCAN", IMPORT{db}="DM_DISABLE_OTHER_RULES_FLAG_OLD"
  31. ENV{DM_SUBSYSTEM_UDEV_FLAG0}!="1", ENV{DM_NOSCAN}=="1", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="$env{DM_DISABLE_OTHER_RULES_FLAG_OLD}", \
  32. ENV{DM_DISABLE_OTHER_RULES_FLAG_OLD}="", ENV{DM_NOSCAN}=""
  33. ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end"
  34. # Do not create symlinks for inappropriate subdevices.
  35. ENV{DM_LV_NAME}=="pvmove?*|?*_vorigin", GOTO="lvm_disable"
  36. ENV{DM_LV_LAYER}=="?*", GOTO="lvm_disable"
  37. # Create symlinks for top-level devices only.
  38. ENV{DM_VG_NAME}=="?*", ENV{DM_LV_NAME}=="?*", SYMLINK+="$env{DM_VG_NAME}/$env{DM_LV_NAME}", GOTO="lvm_end"
  39. LABEL="lvm_disable"
  40. ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
  41. ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
  42. OPTIONS:="nowatch"
  43. LABEL="lvm_end"