8/17/2016 - 1:57 AM

Setting up swap on coreos

Setting up swap on coreos

Setup a swap file in the stateful partition

Run these commands as root to create a 512 megabyte swap.

fallocate -l 512m /media/state/512MiB.swap
chmod 600 /media/state/512MiB.swap
mkswap /media/state/512MiB.swap

Create a unit to initialize it on boot

Create a unit file at /media/state/units/swapon.service with these contents:

Description=Turn on swap

ExecStart=/sbin/swapon /media/state/512MiB.swap


Enable the unit and start using swap

systemctl enable --runtime /media/state/units/swapon.service
systemctl start swapon

On your next reboot the swap will be turned on automatically.