mdadm-fix-udev-rules.patch 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. diff --git a/Makefile b/Makefile
  2. index b6edb23..bedef96 100644
  3. --- a/Makefile
  4. +++ b/Makefile
  5. @@ -253,8 +253,9 @@
  6. $(INSTALL) -D -m 644 md.4 $(DESTDIR)$(MAN4DIR)/md.4
  7. $(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
  8. -install-udev: udev-md-raid.rules
  9. - $(INSTALL) -D -m 644 udev-md-raid.rules $(DESTDIR)/lib/udev/rules.d/64-md-raid.rules
  10. +install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules
  11. + $(INSTALL) -D -m 644 udev-md-raid-arrays.rules $(DESTDIR)/usr/lib/udev/rules.d/63-md-raid-arrays.rules
  12. + $(INSTALL) -D -m 644 udev-md-raid-assembly.rules $(DESTDIR)/usr/lib/udev/rules.d/64-md-raid-assembly.rules
  13. uninstall:
  14. rm -f $(DESTDIR)$(MAN8DIR)/mdadm.8 $(DESTDIR)$(MAN8DIR)/mdmon.8 $(DESTDIR)$(MAN4DIR)/md.4 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5 $(DESTDIR)$(BINDIR)/mdadm
  15. diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules
  16. new file mode 100644
  17. index 0000000..883ee4d
  18. --- /dev/null
  19. +++ b/udev-md-raid-arrays.rules
  20. @@ -0,0 +1,35 @@
  21. +# do not edit this file, it will be overwritten on update
  22. +
  23. +SUBSYSTEM!="block", GOTO="md_end"
  24. +
  25. +# handle md arrays
  26. +ACTION!="add|change", GOTO="md_end"
  27. +KERNEL!="md*", GOTO="md_end"
  28. +
  29. +# partitions have no md/{array_state,metadata_version}, but should not
  30. +# for that reason be ignored.
  31. +ENV{DEVTYPE}=="partition", GOTO="md_ignore_state"
  32. +
  33. +# container devices have a metadata version of e.g. 'external:ddf' and
  34. +# never leave state 'inactive'
  35. +ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state"
  36. +TEST!="md/array_state", ENV{SYSTEMD_READY}="0", GOTO="md_end"
  37. +ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end"
  38. +LABEL="md_ignore_state"
  39. +
  40. +IMPORT{program}="/usr/bin/mdadm --detail --export $devnode"
  41. +ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace"
  42. +ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}"
  43. +ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}"
  44. +ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace"
  45. +ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n"
  46. +ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n"
  47. +ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n"
  48. +
  49. +IMPORT{builtin}="blkid"
  50. +OPTIONS+="link_priority=100"
  51. +OPTIONS+="watch"
  52. +ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
  53. +ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
  54. +
  55. +LABEL="md_end"
  56. diff --git a/udev-md-raid-assembly.rules b/udev-md-raid-assembly.rules
  57. new file mode 100644
  58. index 0000000..b89775e
  59. --- /dev/null
  60. +++ b/udev-md-raid-assembly.rules
  61. @@ -0,0 +1,19 @@
  62. +# do not edit this file, it will be overwritten on update
  63. +
  64. +# assemble md arrays
  65. +
  66. +SUBSYSTEM!="block", GOTO="md_inc_end"
  67. +
  68. +# handle potential components of arrays (the ones supported by md)
  69. +ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_inc"
  70. +GOTO="md_inc_end"
  71. +
  72. +LABEL="md_inc"
  73. +
  74. +# remember you can limit what gets auto/incrementally assembled by
  75. +# mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY'
  76. +ACTION=="add", RUN+="/usr/bin/mdadm --incremental $devnode --offroot"
  77. +ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/usr/bin/mdadm -If $name --path $env{ID_PATH}"
  78. +ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/usr/bin/mdadm -If $name"
  79. +
  80. +LABEL="md_inc_end"
  81. diff --git a/udev-md-raid.rules b/udev-md-raid.rules
  82. deleted file mode 100644
  83. index cc7f5ef..0000000
  84. --- a/udev-md-raid.rules
  85. +++ /dev/null
  86. @@ -1,49 +0,0 @@
  87. -# do not edit this file, it will be overwritten on update
  88. -
  89. -SUBSYSTEM!="block", GOTO="md_end"
  90. -
  91. -# handle potential components of arrays (the ones supported by md)
  92. -ENV{ID_FS_TYPE}=="ddf_raid_member|isw_raid_member|linux_raid_member", GOTO="md_inc"
  93. -GOTO="md_inc_skip"
  94. -
  95. -LABEL="md_inc"
  96. -
  97. -# remember you can limit what gets auto/incrementally assembled by
  98. -# mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY'
  99. -ACTION=="add", RUN+="/sbin/mdadm --incremental $tempnode --offroot"
  100. -ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}"
  101. -ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name"
  102. -
  103. -LABEL="md_inc_skip"
  104. -
  105. -# handle md arrays
  106. -ACTION!="add|change", GOTO="md_end"
  107. -KERNEL!="md*", GOTO="md_end"
  108. -
  109. -# partitions have no md/{array_state,metadata_version}, but should not
  110. -# for that reason be ignored.
  111. -ENV{DEVTYPE}=="partition", GOTO="md_ignore_state"
  112. -
  113. -# container devices have a metadata version of e.g. 'external:ddf' and
  114. -# never leave state 'inactive'
  115. -ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state"
  116. -TEST!="md/array_state", ENV{SYSTEMD_READY}="0", GOTO="md_end"
  117. -ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end"
  118. -LABEL="md_ignore_state"
  119. -
  120. -IMPORT{program}="/sbin/mdadm --detail --export $tempnode"
  121. -ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace"
  122. -ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}"
  123. -ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}"
  124. -ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace"
  125. -ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n"
  126. -ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n"
  127. -ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n"
  128. -
  129. -IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
  130. -OPTIONS+="link_priority=100"
  131. -OPTIONS+="watch"
  132. -ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
  133. -ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
  134. -
  135. -LABEL="md_end"