By checking the swap size in my Ubuntu server I observed that is set to zero. Since it was installed in very basic configuration from AWS EC2, I'm not sure if I had to do additional steps to adjust swap size area.
I run the following commands and got the below results :
# grep Swap /proc/meminfo
SwapCached: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
# swapon -s
# free -m
total used free shared buff/cache available
Mem: 7975 187 7059 0 728 7549
Swap: 0 0 0
# cat /proc/swaps
Filename Type Size Used Priority
Is it normal to have a swap area set to zero ? If it is not, what should I do to fix it ?
Thanks !
Best Answer
For some reason, some cloud (VPS) providers disable the swap in their (modified) installations. Nowadays Ubuntu support swap file, thus you do not need a separate partition for swap. To enable the swap via swap file follow these steps:
Edit
/etc/fstab
and make the changes permanent. Use these commands to do the changes:Or edit
/etc/fstab
and add the the following entry manually:That is it.
Ideas for additional tweaks (I would prefer to use the default settings for normal swap usage):
Change the frequency of RAM to SWAP data copy:
Change the frequency of Cache flush:
Make the above changes permanent:
Or edit
/etc/sysctl.conf
and add the the following entries manually: