Increase performance by reducing swappiness

Back to the home page

Swap use (swappiness) is too high: Mint is too slow and uses the hard disk too much

This is especially noticeable on computers with relatively low RAM memory: they tend to be far too slow in Linux Mint, and Mint accesses the hard disk too much. Luckily, this can be helped.

Note: does your computer have 8 GB RAM or more? Then you might skip this item, because with so much RAM you probably won't notice any benefits from applying it.

On the hard disk there's a separate file or partition for virtual memory, called the swap. When Mint uses the swap too much, the computer slows down a lot.

Mints inclination to use the swap, is determined by a setting called swappiness. The lower the setting, the longer it takes before Mint starts using the swap. On a scale of 0-100, the default setting is 60. Which is much too high for normal desktop use; the optimal compromise is probably 20.

A detailed explanation can be found here (link dead? Then download this pdf file with the same content).

Now the how-to for decreasing the swappiness to a more reasonable level, namely 20:

a. First check your current swappiness setting:

Launch a terminal window.
(You can launch a terminal window like this: *Click*)

Type (use copy/paste):

cat /proc/sys/vm/swappiness

Press Enter.

The result will probably be 60.

b. Then type in the terminal (use copy/paste):

xed admin:///etc/sysctl.conf

Press Enter.

Scroll to the bottom of the text file and add your swappiness parameter to override the default, so copy/paste the following two blue lines into the text file:

# Decrease swap usage to a more reasonable level

c. Save the modified text file and reboot your computer.

d. After the reboot, check the new swappiness setting:

Launch a terminal and type (use copy/paste):

cat /proc/sys/vm/swappiness

Press Enter.

Now it should be 20.

Note: if your hard disk is an SSD, there's an extra reason to decrease the default swappiness. That's because too many write actions, like frequent swapping, reduce the lifespan of an SSD. Also check these tips for optimizing an SSD for your Linux.

Only 4 GB RAM or less: increase zswap

When your computer doesn't have much RAM (4 GB or less), then of course your best choice for speed is a lightweight member of the Mint family, like Mint Xfce. But even then the "lack" of memory will remain a problem, which will cause your system to slow down from time to time. Even when the swappiness has been decreased to 20.

In that case, you'll often achieve better results by increasing the maximum for zswap. By default, zswap uses up to 20 percent of the RAM memory. It's a kernel feature that provides a compressed RAM cache for swap pages.

Pages which would otherwise be swapped out to disk are instead compressed and stored into a memory pool in RAM. Once the pool is full or the RAM is exhausted, the least recently used page is decompressed and written to disk, as if it had not been intercepted. After the page has been decompressed into the swap cache, the compressed version in the pool will be freed.

With "only" 4 GB RAM or less, I recommend to double zswap to 40 percent (not more!).

The price you pay for this, is twofold:

- Your processor (CPU) is being taxed more heavily, because it'll have to compress and decompress more;

- When the system has filled the RAM swap, it'll start swapping on the hard drive as well. With a heavy burden on the available RAM: the chunk of memory that has been sacrificed for the RAM swap.

That's why I advise to increase zswap only for computers with not so much RAM, and even then only in combination with a swappiness that has been set to 20.

You can increase zswap as follows:

a. Launch a terminal window.
(You can launch a terminal window like this: *Click*)

b. Copy/paste the following command line into the terminal:

xed admin:///etc/default/grub

Press Enter.

(the three consecutive slashes are intended and no typo!)

c. Find the following line:


Add zswap.max_pool_percent=40 between the quotation marks, or simply replace the entire line by the following line (use copy/paste):


Save the modified file and close it.

d. Copy/paste the following command line into the terminal, in order to execute the modification:

sudo update-grub

Press Enter. Type your password when prompted. In Ubuntu this remains entirely invisible, not even dots will show when you type it, that's normal. In Mint this has changed: you'll see asterisks when you type. Press Enter again.

(if you type the command: note the dash between update and grub)

e. Reboot your computer.

You can check whether the change has been implemented with this command:

cat /sys/module/zswap/parameters/max_pool_percent

It should report 40 now.

Warning: there's also RAM swap feature called zRam. Don't install that, because it's counterproductive in combination with zswap!

Want more?

Do you want more tips and tweaks? There's a lot more of them on this website!

For example:

Speed up your Linux Mint!

Clean your Linux Mint safely

Avoid 10 fatal mistakes

To the content of this website applies a Creative Commons license.

Back to the home page