Modify Your Swapfile For Better Performance
By on August 7th, 2009

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.

Author: Chinmoy Kanjilal Google Profile for Chinmoy Kanjilal
Chinmoy Kanjilal is a FOSS enthusiast and evangelist. He is passionate about Android. Security exploits turn him on and he loves to tinker with computer networks. He rants occasionally at Techarraz.com. You can connect with him on Twitter @ckandroid.

Chinmoy Kanjilal has written and can be contacted at chinmoy@techie-buzz.com.

Leave a Reply

Name (required)

Website (optional)

 
    Warning: call_user_func() expects parameter 1 to be a valid callback, function 'advanced_comment' not found or invalid function name in /home/keith/techie-buzz.com/htdocs/wp-includes/comment-template.php on line 1694
 
Copyright 2006-2012 Techie Buzz. All Rights Reserved. Our content may not be reproduced on other websites. Content Delivery by MaxCDN