How to enable Swap / Swappines on Digital Hosting

1. Check if you haven’t got swap. I didn’t by default it seems it does not get created.

# free   – This will display available memory

# fallocate -l 1G /mnt/1GB.swap

# mkswap /mnt/1GB.swap

# swapon /mnt/1GB.swap

and add the records to your /etc/fstab

# echo “/mnt/1GB.swap none swap sw 0 0” >> /etc/fstab

Now display your swappines value

# cat /proc/sys/vm/swappiness

normally it’s 60 ( This means that Kernel is more likely to put things into Swap than memory)

Swappiness it is just a value it does not mean that were you memory will be able at 60% it will start putting things to swap.

You may find it useful although 10 should be fine you can always tune it later if needed.

The swap tendency can have a value of 0 (fully off) to 100 (swap is constantly used).

sudo sysctl vm.swappiness=10

then add it to your
vim /etc/sysctl.conf

and for the god sake of LOL reboot yourserver

#shutdown -R now

A workable and practical rule for changing the swappiness can be:
1 GB or more RAM: 10
Less than 1 GB of RAM: 1



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s