Created
March 13, 2019 21:25
-
-
Save bwDraco/a033ee5935bdcbfb57a5f64dacc6196c to your computer and use it in GitHub Desktop.
Simple systemd service to automate turning zram swap on and off
This file contains 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 | |
set -e | |
swapoff /dev/zram0 | |
echo 1 > /sys/block/zram0/reset |
This file contains 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 | |
set -e | |
modprobe -v zram | |
echo 1G > /sys/block/zram0/disksize | |
mkswap /dev/zram0 | |
swapon -d /dev/zram0 |
This file contains 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
[Unit] | |
Description=Compressed Memory Swap | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/local/sbin/zramswap-on.sh | |
ExecStop=/usr/local/sbin/zramswap-off.sh | |
RemainAfterExit=yes | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment