Modify Your Swapfile For Better Performance

by Chinmoy Kanjilal | Translate | Print
Friday, 07th Aug 2009 | Share


Share Modify Your Swapfile For Better Performance on Twitter Share Modify Your Swapfile For Better Performance on Facebook Save Modify Your Swapfile For Better Performance To Delicious Favorites Stumble Modify Your Swapfile For Better Performance Share Modify Your Swapfile For Better Performance on Digg Get Instant Updates as RSS Feeds from Techie Buzz

A swap file is an area on your hard-disk where the computer continuously keeps storing data which is not in immediate use. Now, a drive failure of the swap partition can cause some applications which require high amount of swap memory to crash.

There are two workarounds to this :

  1. Firstly, you can reduce the system swappiness. With this, you can set the system to use less swap memory. The possible values are from 0 to 100.
    Just run the command :

    sysctl vm.swappiness=desired swappiness

    Here, replace ‘desired swappiness’ with a desired value between 0 to 100. 0 indicates no swap usage, thereby running everything on the RAM, unless absolutely necessary, 100 indicates immediate swapping.For this to take effect without a reboot, run

    swapoff -a

    and

    swapon -a

    as root.

  2. Using a swap file.
    Using a swap file has it’s own advantages. A separate swap partition has to be fully functional and error free at all times. Also, it eats up some time of the already slow Linux bootup process. With a swap file, you can adjust it’s size, So, to use a swap file, become root. Then follow the steps below.

    • Create an empty file with the command :
      dd if=/dev/zero of=/swapfile bs=1048576 count=1000
    • Create a swapfile :
      mkswap /swpf
    • Turn it on.
      swapon /swpf
    • Add the line
    • /swapfile    swap   swap  defaults 0

      to the file /etc/fstab for doing this permanently.

  3. Check the creation using :
    swapon -s

That is all. Get a better and faster debian based system in a few seconds, without any restart.



Share

No Responses so far | Share Your Opinions!

Leave a Comment

Note: We discourage users from using keywords in their names while posting comments, most of them get caught by spam, also it really would be more fruitful in knowing people who comment by their real name, rather than by using a name no one relates to. In future we reserve the right to delete comments from users using a name other than their own.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>