Swap: Difference between revisions
m Text replacement - "<(\/?)source" to "<$1syntaxhighlight" |
No edit summary |
||
| Line 1: | Line 1: | ||
Swap memory is a file-system based temporary storage for memory to allow a system to shuffle between different tasks that would otherwise consume all available physical memory (RAM). Cloud providers like [[AWS]]<ref>https://serverfault.com/questions/218750/why-dont-ec2-ubuntu-images-have-swap</ref> and [[Digital Ocean]]<ref>https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04</ref> do not setup swap on their default images. So, it's up to you to enable swap. RedHat provides | Swap memory is a file-system based temporary storage for memory to allow a system to shuffle between different tasks that would otherwise consume all available physical memory (RAM). Cloud providers like [[AWS]]<ref>https://serverfault.com/questions/218750/why-dont-ec2-ubuntu-images-have-swap</ref> and [[Digital Ocean]]<ref>https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04</ref> do not setup swap on their default images. So, it's up to you to enable swap. RedHat provides [https://www.redhat.com/en/blog/do-we-really-need-swap-modern-systems an overview of swap] where you can learn the basics of Virtual Memory Management, paging, swapping, and thrashing. | ||
== Procedure == | |||
Here's a procedure that you can run as root, or an administrative user with sudo privileges. | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
# see if it's enabled? | # see if it's enabled? | ||
| Line 22: | Line 25: | ||
swapon -s | swapon -s | ||
# make it permanent in the file system | # make it permanent in the file system | ||
echo /swapfile none swap sw 0 0 | tee -a /etc/fstab | echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab | ||
# there are some other problems with a default Droplet | # there are some other problems with a default Droplet | ||
# swappiness is too high, and cache pressure is too high | # swappiness is too high, and cache pressure is too high | ||
cat << HERE | cat << HERE | sudo tee -a /etc/sysctl.d/10-swap.conf | ||
# swappiness for a VM should be closer to zero | # swappiness for a VM should be closer to zero | ||
# 60 might be good for a desktop | # 60 might be good for a desktop | ||
| Line 38: | Line 41: | ||
HERE | HERE | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Feature == | |||
This is the subject of a feature request https://github.com/freephile/meza/issues/176 | |||
[[Category:System Administration]] | [[Category:System Administration]] | ||
[[Category:Cloud]] | [[Category:Cloud]] | ||