Encouraging Linux not to use the SWAP partition


I recently doubled the memory in my eee PC 1005HA netbook running Mint 16 from 1Gb to 2Gb and to try to maintain the 7 hours battery life I get out of it decided to reduce the possibility of it using the swap drive unless necessary. My initial thought was to delete the swap partition but after some research decided that this was not a good idea, it would be better to discourage Linux from using the SWAP partition!

I came across an excellent post written in 2012 by mikecrosoft in the Linux Mint Forums which clearly explains the steps. As I can’t improve it have reproduced it below. Of course this would apply to all modern day Linux systems, so I’ve since applied it to all of my desktop PCs and to my HP Sleekbook laptop.

I think there is really no problem with letting your system use some swap space, but if you really need to decrease the priority of Virtual Memory vs RAM usage you can simply change the swappiness value; to do that it would be as follows (extracted from https://help.ubuntu.com/community/SwapFaq, and tested so many times in the past and once while writing the comment):

** This would be just in case you haven’t deleted your swap partition or permanently modified anything related, I’ve read you have already deleted your swap partition so I post this just in case somebody needs a less aggressive approach **

1. Open a terminal

2. Type:

cat /proc/sys/vm/swappiness

3. That will display your swappiness actual value (60)

4. If you are going to be testing your system performance during some time to see if you really need to make this change permanent or if you’re going to try with different swappiness values until you find the optimum one, I suggest you to create a launcher in your desktop with the following command:

gksudo sysctl vm.swappiness=10

5. That will change your swappiness value to 10 when you double click the launcher, to try with different values just replace 10 by any integer number in the range 0-100

6. Once you have find the optimum value and decided to make changes permanent, open a terminal and type:

sudo gedit /etc/sysctl.conf

7. Search for vm.swappiness and change its value as desired. If vm.swappiness does not exist, add it to the end of the file like so:

vm.swappiness=10
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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