Skip to content
Shellbay

Server Operations · about 3 min · 5 steps

Swap file

Adds a swap file so the server slows down instead of stopping programs when memory runs out.

Runs on

  • Debian / Ubuntu: supported
  • RHEL / Fedora: supported
  • Alpine: supported

What it changes on your server

  • Creates /swapfile (readable by root only), unless it already exists.
  • Turns swap on now and adds it to /etc/fstab for reboots.
  • Sets vm.swappiness to 10 in /etc/sysctl.d/99-shellbay-swap.conf.

What Shellbay asks you

  1. How large should the swap file be?

    A common choice is the same as the server's memory, up to 4 GB. Swap uses disk space, so Shellbay checks there's room for it plus 1 GB to spare.

    Size in GB
    A whole number from 1 to 64. Default: 2

    Example: 2

    Shellbay checks the server has enough free disk space.

Steps

  1. Create the swap file
  2. Turn on swap
  3. Keep swap on after reboots
  4. Prefer memory over swap
  5. Check swap is active

Shellbay checks the server before the first step, and stops at the first step that fails.

When it's done

  • Swap is on. It stays on after reboots.