Modify Your Swapfile For Better Performance
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 :
- 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.
- 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.
- Create an empty file with the command :
- Check the creation using :
swapon -s
That is all. Get a better and faster debian based system in a few seconds, without any restart.
Comment Using Facebook
One Response to this Article | Share your Opinions/Comments
We moderate comments to prevent spam. Moderation is done within few hours. Please try and stay on topic and refrain from using abusive language. If you think there is a problem with this post, please email the post author or send us an email at tips@techie-buzz.com with the URL and the problem you see and we will rectify it as soon as we can.



About :
mkswap /swpf
swapon /swpf
I think it should be /swapfile instead of /swpf, am I right ?