parse-dmsquash-live.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. # live images are specified with
  3. # root=live:backingdev
  4. [ -z "$root" ] && root=$(getarg root=)
  5. # support legacy syntax of passing liveimg and then just the base root
  6. if getargbool 0 rd.live.image -d -y liveimg; then
  7. liveroot="live:$root"
  8. fi
  9. if [ "${root%%:*}" = "live" ] ; then
  10. liveroot=$root
  11. fi
  12. [ "${liveroot%%:*}" = "live" ] || return 1
  13. modprobe -q loop
  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" ] || return 1
  47. info "root was $liveroot, is now $root"
  48. # make sure that init doesn't complain
  49. [ -z "$root" ] && root="live"
  50. wait_for_dev -n /dev/mapper/live-rw
  51. return 0