03-zram.sh 408 B

12345678910111213141516171819202122232425262728
  1. # shellcheck shell=sh
  2. (
  3. [ "${ZRAM_COUNT}" ] && \
  4. [ "${ZRAM_ALGO}" ] && \
  5. [ "${ZRAM_SIZE}" ] || \
  6. exit
  7. : "${ZRAM_PRI:=10}"
  8. set --
  9. msg 'creating ZRAMS'
  10. i=1; while [ "${i}" -le "${ZRAM_COUNT}" ]; do
  11. set -- "${@}" "$(zramctl -f -s "${ZRAM_SIZE}" -a "${ZRAM_ALGO}")"
  12. : $(( i += 1 )); done
  13. for zram; do
  14. mkswap "${zram}"
  15. done
  16. msg 'mounting ZRAMS'
  17. for zram; do
  18. swapon -p "${ZRAM_PRI}" "${zram}"
  19. done
  20. ) &