Last active
June 3, 2026 17:54
-
-
Save ohaiibuzzle/3d23d385beca97f8091277d68312340e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/sbin/openrc-run | |
| ZRAM_SIZE=96M | |
| ZRAM_ALGO=zstd | |
| start() { | |
| ebegin "Starting ${RC_SVCNAME}" | |
| modprobe zram num_devices=1 | |
| echo ${ZRAM_ALGO} > /sys/block/zram0/comp_algorithm | |
| echo ${ZRAM_SIZE} > /sys/block/zram0/disksize | |
| mkswap /dev/zram0 > /dev/null | |
| swapon /dev/zram0 | |
| eend $? | |
| } | |
| stop() { | |
| ebegin "Stopping ${RC_SVCNAME}" | |
| swapoff /dev/zram0 | |
| modprobe -r zram | |
| eend $? | |
| } | |
| depend() { | |
| need localmount | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| ZRAM_SIZE=96M | |
| ZRAM_ALGO=zstd | |
| start() { | |
| echo "Setting up zram with ${ZRAM_SIZE} and ${ZRAM_ALGO} compression..." | |
| echo ${ZRAM_ALGO} > /sys/block/zram0/comp_algorithm | |
| echo ${ZRAM_SIZE} > /sys/block/zram0/disksize | |
| mkswap /dev/zram0 > /dev/null | |
| swapon /dev/zram0 | |
| } | |
| stop() { | |
| echo "Tearing down zram..." | |
| swapoff /dev/zram0 | |
| echo 1 > /sys/block/zram0/reset | |
| } | |
| case "$1" in | |
| start) | |
| start | |
| ;; | |
| stop) | |
| stop | |
| ;; | |
| restart) | |
| stop | |
| sleep 1 | |
| start | |
| ;; | |
| *) | |
| echo "Usage: $0 {start|stop|restart}" | |
| exit 1 | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment