-
-
Save zz/6358d07bc9a3c1dbfc39 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
# swith to sudo | |
sudo -i | |
# create swap | |
touch /2GiB.swap | |
chattr +C /2GiB.swap | |
fallocate -l 2048m /2GiB.swap | |
chmod 600 /2GiB.swap | |
mkswap /2GiB.swap | |
# create service unit to start swap [/etc/systemd/system/swap.service] | |
[Unit] | |
Description=Turn on swap | |
[Service] | |
Type=oneshot | |
Environment="SWAPFILE=/2GiB.swap" | |
RemainAfterExit=true | |
ExecStartPre=/usr/sbin/losetup -f ${SWAPFILE} | |
ExecStart=/usr/bin/sh -c "/sbin/swapon $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)" | |
ExecStop=/usr/bin/sh -c "/sbin/swapoff $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)" | |
ExecStopPost=/usr/bin/sh -c "/usr/sbin/losetup -d $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)" | |
[Install] | |
WantedBy=multi-user.target | |
# add service and start | |
systemctl enable /etc/systemd/system/swap.service | |
systemctl start swap | |
# reboot | |
reboot | |
# Options | |
cat /proc/sys/vm/swappiness | |
sysctl vm.swappiness=10 | |
sysctl vm.vfs_cache_pressure=50 | |
https://github.com/coreos/docs/issues/52 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment