How to turn off swap in Linux. Not every Linux server I administer needs to have a swap partition and to start swapping. For instance, the MySQL servers I maintain all have more than enough RAM on board to do their work. Yet, when a swap partition is enabled Linux starts swapping, which may degrade MySQL database performance…
An unwanted Linux swap partition can be the result of an automated and unattended Linux installation. Of course you can fiddle with the Linux kernel
swapiness settings, located in
/proc/sys/vm/swapiness and configurable in
/etc/sysctl.conf, but one can turn off the swap completely too.
Here’s a tiny bash script to disable Linux’ swap – for which we use the swapoff command – and to comment out the swap partition in
#!/bin/bash # swapoff -a to disable swapping swapoff -a # sed to comment the swap partition in /etc/fstab sed -i.bak -r 's/(.+ swap .+)/#\1/' /etc/fstab
Save this as
turn_swap_off.sh and execute as root:
A backup of the
/etc/fstab file is made just to be sure and to stay on the safe side.
My name is Jan. I am not a hacker, coder, developer, programmer or guru. I am merely a system administrator, doing my daily thing at Vevida in the Netherlands. With over 15 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, WordPress, websites & optimization. Want to support me and donate? Use this link: https://paypal.me/jreilink.
Release hold queue email in Postfix – postsuper
Recursive scp and symlinks
Install Varnish Cache on CentOS 6.7
Install Elasticsearch on CentOS 6.7
Generate pseudo-random passwords with OpenSSL
New Open-Xchange merger: PowerDNS
Monit monitoring on Ubuntu 14.04 VM on Hyper-V
How to restore a deleted Open-Xchange context?