swap partition not present

Post Reply
mister_v
Posts: 140
Joined: Sat Jun 20, 2009 5:42 pm

swap partition not present

Post 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 ?
Chris
Site Admin
Posts: 130
Joined: Mon Jul 21, 2008 9:45 am
Location: Leuven, Belgium
Contact:

Re: swap partition not present

Post 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
Post Reply