dmsquash-generator.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/bin/sh
  2. modprobe usb_storage
  3. modprobe dm_mod
  4. type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
  5. [ -z "$root" ] && root=$(getarg root=)
  6. # support legacy syntax of passing liveimg and then just the base root
  7. if getargbool 0 rd.live.image -d -y liveimg; then
  8. liveroot="live:$root"
  9. fi
  10. if [ "${root%%:*}" = "live" ] ; then
  11. liveroot=$root
  12. fi
  13. [ "${liveroot%%:*}" = "live" ] || exit 0
  14. case "$liveroot" in
  15. live:LABEL=*|LABEL=*) \
  16. root="${root#live:}"
  17. root="$(echo $root | sed 's,/,\\x2f,g')"
  18. root="live:/dev/disk/by-label/${root#LABEL=}"
  19. rootok=1 ;;
  20. live:CDLABEL=*|CDLABEL=*) \
  21. root="${root#live:}"
  22. root="$(echo $root | sed 's,/,\\x2f,g')"
  23. root="live:/dev/disk/by-label/${root#CDLABEL=}"
  24. rootok=1 ;;
  25. live:UUID=*|UUID=*) \
  26. root="${root#live:}"
  27. root="live:/dev/disk/by-uuid/${root#UUID=}"
  28. rootok=1 ;;
  29. live:PARTUUID=*|PARTUUID=*) \
  30. root="${root#live:}"
  31. root="live:/dev/disk/by-partuuid/${root#PARTUUID=}"
  32. rootok=1 ;;
  33. live:PARTLABEL=*|PARTLABEL=*) \
  34. root="${root#live:}"
  35. root="live:/dev/disk/by-partlabel/${root#PARTLABEL=}"
  36. rootok=1 ;;
  37. live:/*.[Ii][Ss][Oo]|/*.[Ii][Ss][Oo])
  38. root="${root#live:}"
  39. root="liveiso:${root}"
  40. rootok=1 ;;
  41. live:/dev/*)
  42. rootok=1 ;;
  43. live:/*.[Ii][Mm][Gg]|/*.[Ii][Mm][Gg])
  44. [ -f "${root#live:}" ] && rootok=1 ;;
  45. esac
  46. [ "$rootok" != "1" ] && exit 0
  47. GENERATOR_DIR="$2"
  48. [ -z "$GENERATOR_DIR" ] && exit 1
  49. [ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR"
  50. ROOTFLAGS="$(getarg rootflags)"
  51. {
  52. echo "[Unit]"
  53. echo "Before=initrd-root-fs.target"
  54. echo "[Mount]"
  55. echo "Where=/sysroot"
  56. echo "What=/dev/mapper/live-rw"
  57. [ -n "$ROOTFLAGS" ] && echo "Options=${ROOTFLAGS}"
  58. } > "$GENERATOR_DIR"/sysroot.mount
  59. mkdir -p "$GENERATOR_DIR/dev-mapper-live\x2drw.device.d"
  60. {
  61. echo "[Unit]"
  62. echo "JobTimeoutSec=3000"
  63. } > "$GENERATOR_DIR/dev-mapper-live\x2drw.device.d/timeout.conf"