Sunday, September 26, 2010

Create a Temporary Swap file in Ubuntu

SomeTimes you may have to run a program that consumes more of your Main Memory and you may need more swap memory. Well, One way to create a temporary swap file is described below....its no way as efficient as original swap. But still it serves the purpose...

first of all, check your present swap space..

$free


Now, lets create a empty swap file..

$sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024

Notice bs=1024 is the block size in KBs and count=1024 is number of blocks. So you can decide your memory requirements accordingly.

$sudo mkswap /swapfile

switch on the swap file...

$sudo swapon /swapfile

Now again run the free command to notice the increase in swap memory.

$free

you can also free the space by switching it off.

$sudo swapoff /swapfile

NOTE: This swap memory will not be there when you reboot your pc. To retain it, you can make a entry in /etc/fstab file or again run the commands from 3rd step.

No comments:

 
Copyright 2009 ENDEAVOR