Adding swap files in times of need
Environment
RHEL, CentOS
Description
Process for adding a swap file during memory pressure. Your system has been operational for some time and an issue is present that is consuming RAM. You cant pause, migrate or kill it off so to ride the storm you need to add more virtual memory.
Example for 32GB estimated memory to root /. Ensure sufficient storage space is available first. Adjust count to create file of different size.
Steps
ionice -c 3 dd if=/dev/zero of=/mnt/32GB.swap bs=64M count=512
chown root:root /mnt/32GB.swap
chmod 0600 /mnt/32GB.swap
mkswap /mnt/32GB.swap
swapon /mnt/32GB.swap