Created
December 1, 2014 10:05
-
-
Save romaninsh/118952ce61643914fb00 to your computer and use it in GitHub Desktop.
Set up swap on CoreOS
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
create this file in your /root folder | |
$ fleetctl load swapon.service | |
$ fleetctl start swapon.service | |
This will create swap file on all nodes of your CoreOS cluster without prior setup. | |
See also http://cloudinit.readthedocs.org/en/latest/topics/examples.html#adjust-mount-points-mounted |
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=Turn on swap | |
[Service] | |
Type=oneshot | |
Environment="SWAPFILE=/4GiB.swap" | |
RemainAfterExit=true | |
ExecStartPre=/usr/bin/touch ${SWAPFILE} | |
ExecStartPre=/usr/bin/fallocate -l 4096m ${SWAPFILE} | |
ExecStartPre=/usr/bin/chmod 600 ${SWAPFILE} | |
ExecStartPre=/usr/sbin/mkswap ${SWAPFILE} | |
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 | |
[X-Fleet] | |
Global=true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!