Question

My Ubuntu server not using available swap, even if OOM. What to do?

I recently added 1 GB of swap to my Ubuntu server to prevent MySQL crashes on RAM overloading. I followed this tutorial: https://www.digitalocean.com/community/articles/how-to-configure-virtual-memory-swap-file-on-a-vps.

I use htop to monitor resources. When I use loadimpact to test my server it crashes when no more RAM is available, but not a single byte of swap is used…

I got the current setting now:

swapon -s

Filename Type Size Used Priority /var/swap.img file 1023996 0 100

free

               total       used       free     shared    buffers     cached

[…] Swap: 999 0 999

/etc/fstab contains: LABEL=DOROOT / ext4 errors=remount-ro 0 1 /var/swap.img none swap defaults,pri=100 0 0

Last note: when I used the tutorial I get the following msg executing “swapon -p 100 /var/swap.img” : swapon: /var/swap.img: swapon failed: Device or resource busy


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

What is it set to?

No, swappiness is already set.

Does running <code>sysctl vm.swappiness=10</code> fix it?