Last active
August 1, 2018 14:51
-
-
Save steigr/cc4be305e06bc6c7e0b0dfac7a75b189 to your computer and use it in GitHub Desktop.
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
# install via | |
# curl -sL https://gist.github.com/steigr/cc4be305e06bc6c7e0b0dfac7a75b189/raw/swapspace.service | install -D -m 0644 /dev/stdin /etc/systemd/system/swapspace.service && systemctl enable --now swapspace | |
[Service] | |
ExecStartPre=-/usr/bin/env mkdir -p /opt/bin /var/lib/swapspace | |
ExecStartPre=-/usr/bin/env swapoff /var/lib/swapspace/base.swap | |
ExecStartPre=-/usr/bin/env dd if=/dev/zero of=/var/lib/swapspace/base.swap bs=1M count=1 | |
ExecStartPre=-/usr/bin/env chmod 0600 /var/lib/swapspace/base.swap | |
ExecStartPre=-/usr/bin/env mkswap /var/lib/swapspace/base.swap | |
ExecStartPre=-/usr/bin/env swapon /var/lib/swapspace/base.swap | |
ExecStartPre=/usr/bin/env bash -c 'test -s /opt/bin/swapspace || curl -sL https://github.com/mathias-kaufmann/swapspace/releases/download/1.10/swapspace | install -m 0744 /dev/stdin /opt/bin/swapspace' | |
ExecStart=/opt/bin/swapspace | |
ExecStopPost=/usr/bin/env bash -c 'swapon --show=NAME --noheadings | xargs -I{} bash -c "swapoff {} && rm {}"' | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment