Add swap file to CentOS 7, Amazon AWS

move to super user
sudo su
create 1GB swap file
dd if=/dev/zero of=/myswap bs=1M count=1024
only root should have access
chown root:root /myswap
chmod 0600 /myswap
At this point the content of / are:
format as swap
mkswap /myswap
last check without swap on:
free -m
announce to system
swapon /myswap
there should be swap on now:
free -m
vi /etc/fstab
UUID=cf990154-eb88-40fc-88f2-f208d0b88c2a /                       xfs     defaults        0 0
/myswap swap swap defaults 0 0
Here is full file:
This configuration causes such a trouble. Now to reboot the computer it is more required to manually stop thing:
systemctl stop httpd zabbix-agent zabbix-server mariadb && sleep 1 && swapoff -a && sleep 1 && reboot
or wait 30 minutes for reboot to succeed by default.

No comments: