Page 1 of 1

swap partition not present

Posted: Wed Sep 10, 2025 4:36 pm
by mister_v
I got a problem with my swap space.

I got a small server with 1Gb ram.
It is getting to its limit.
It want to swap out memory but because there is no partition for swap,
so it is killing some processes.

How can i fix this, without adding a partition ?

Re: swap partition not present

Posted: Wed Sep 10, 2025 7:01 pm
by Chris
You can choose to add a swap-file.
Similar to what windows does.

you create a swap-file, usually in root. But do it on the partition with the most space.

Code: Select all

sudo fallocate -l 2G /swapfile
Usually you take 2 times the available ram, 1G ram x 2 = 2G swapfile.

Assign it read/write permissions for root only (not strictly needed, but more secure)

Code: Select all

sudo chmod 600 /swapfile
Format as swap:

Code: Select all

sudo mkswap /swapfile
And activate it for the current session (no reboot needed)

Code: Select all

sudo swapon /swapfile

You can verify with:

Code: Select all

swapon -s