mdadm_hook 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/ash
  2. run_hook() {
  3. local i= mdconfig=/etc/mdadm.conf
  4. # for partitionable raid, we need to load md_mod first!
  5. modprobe md_mod 2>/dev/null
  6. if [ -n "$md" ]; then
  7. echo 'DEVICE partitions' >"$mdconfig"
  8. for i in $(cat /proc/cmdline); do
  9. case $i in
  10. # raid
  11. md=[0-9]*,/*)
  12. device=${i%%,*}
  13. device=${device/=/}
  14. array=${i#*,}
  15. echo "ARRAY /dev/$device devices=$array"
  16. ;;
  17. # partitionable raid
  18. md=d[0-9]*,/*)
  19. device=${i%%,*}
  20. device=${device/=/_}
  21. array=${i#*,}
  22. echo "ARRAY /dev/$device devices=$array"
  23. ;;
  24. # raid UUID
  25. md=[0-9]*,[0-9,a-fA-F]*)
  26. device=${i%%,*}
  27. device=${device/=/}
  28. array=${i#*,}
  29. echo "ARRAY /dev/$device UUID=$array"
  30. ;;
  31. # partitionable raid UUID
  32. md=d[0-9]*,[0-9,a-fA-F]*)
  33. device=${i%%,*}
  34. device=${device/=/_}
  35. array=${i#*,}
  36. echo "ARRAY /dev/$device UUID=$array"
  37. ;;
  38. esac
  39. done >>"$mdconfig"
  40. fi
  41. # assemble everything
  42. [ -s "$mdconfig" ] && /usr/bin/mdassemble
  43. }
  44. # vim: set ft=sh ts=4 sw=4 et: