Making the GUI faster in Ubuntu Linux

I’ve been using some form of Unix since I was introduced to the Internet my first year at University in 1995. I switched to Linux on the desktop full time in April 2005, and I’ve been managing my company’s mid-size network of servers and desktops for the past two years.

One thing I’ve noticed about Linux, even desktop-focused distributions, is that it’s largely tuned to the most desirable behaviour for a server. But what is desirable on a server isn’t necessarily desirable on a desktop. On Ubuntu Linux (or any Debian-based distro), add the following two lines to /etc/sysctl.conf:


These changes will be done automatically on reboot, but let’s load them now with:

sysctl -p

Now you’ll notice GUI applications feel more responsive and filesystem browsing will be faster when the disk is busy. What we have done is instruct the kernel to prefer to keep applications in RAM (swappiness) instead of disk cache, and to prefer to keep filesystem inodes and directory entries cached at the cost of files themselves. This means reading files from disk is slightly slower (IE, copying, moving, loading big files), but browsing the filesystem will be much faster. wrote extensively on this last year. I recommend his write-up for anyone who wants to understand the issues in more depth.

For the record, I ran the tests in Rudd-o’s article. He advised creating a big file, then displaying the entire filesystem hierachy with find, and then copying that file. In my case, I went from 2 minutes, 6 seconds for the “find / > /dev/null” to just 17 seconds. That has made browsing in Konqueror a great deal faster.


  1. Adam’s avatar

    When I copy those lines verbatim I get:

    root@apu:/etc# sysctl -p
    error: “sysctl -w vm.swappiness” is an unknown key
    error: “sysctl -w vm.vfs_cache_pressure” is an unknown key

    I presume it should be:


    I’m still opening and closing windows trying to see if I notice a difference.


  2. tyler’s avatar

    Oops. I miswrote. Either run those two lines, or put the entries in without “sysctl -w”. I’ll edit the entry shortly.


  3. Hayde’s avatar

    Dear sir,

    Kindly, I need to make setting for cache in ubuntu , im make some command but the cache don’t become active .

    Please learn me about these command if possible my friend ….

    I’ll wait you ….

    Best Regards.



  4. Alan’s avatar

    In our case I wanted to get file system caches out of RAM! Setting the vfs_cache_pressure parameter to a value greater than 100 will tell the kernel to more actively reclaim RAM used by caches. A backup server of ours was swapping heavily, regardless of having 2 gigs of physical RAM and very few applications running.

    I guess file caches being read into RAM were to blame, as the server is actively using rsync to backup about 25 workstations in our small office. The disk thrashing was very heavy, and I found this to resolve the problems:

    sysctl -w vm.swappiness=20
    * Tell the kernel to swap applications out of RAM less (give preference to code rather than data from caches). Might not have done as much to remedy the problem as the other settings below, default is 60 and I might switch back after monitoring.

    sysctl -w vm.vfs_cache_pressure=10000
    * Tell the kernel to reclaim physical RAM used by file system caches more often. Default setting is 100.

    sysctl -w vm.dirty_ratio=2
    * Tell the kernel to keep the dirty page / physical RAM ratio lower, 2%. Default is 10.

    sysctl -w vm.dirty_background_ratio=1
    * Tell the kernel to start swapping dirty pages out as soon as they hit 1% (start flushing out early, before hitting the above ratio)

    Hope this helps someone. For reference, our server is Ubuntu 9.04, kernel 2.6.33, using BackupPC and an ext3 RAID5 (md).


    1. tyler’s avatar

      Thanks, Alan. That’s very helpful. I do a lot with BackupPC. If you have a chance to rebuild this server or replace it, you will be much happier with performance under RAID10. I recently built an identical machine to my backup server, except that it had 4x 1TB disks in RAID-10 configuration instead of 5x 500GB disks in RAID-5. I cloned the BackupPC filesystem to it, and started backups on it. Backups now finish 40% faster and I can run 25% more of them, simultaneously.



Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.