How do I free swap

Eric Shubert ejs at shubes.net
Thu Nov 4 16:00:28 MST 2010


On 11/04/2010 03:26 PM, Bryan O'Neal wrote:
> Please no debates on why I need to clear swap...
>
> If I have a box with 20% free ram and 5% free swap but no paging
> activity - how do I force linux to release the allocated swap? I have
> ~ 2x as much allocated swap as free memory so simply turning swap off
> seems like a bad idea.
>
> Thanks
>

To minimize swap use, put
vm.swappiness = 0
in /etc/sysctl.conf file. You can also change it on the fly in the 
/proc/sys/vm/swappiness.
See http://unixfoo.blogspot.com/2007/11/linux-performance-tuning.html

AFA purging the swap file is concerned, I only know to stop and start it 
again:
# swapoff -a && swapon -a
You might not run into trouble doing this, as there's probably a good 
deal of (filesystem) cached ram being used that the kernel will give up 
if it's needed for running processes. Do the math though to be sure you 
won't run out. Either that or stop some less important processes while 
you do it.

-- 
-Eric 'shubes'



More information about the PLUG-discuss mailing list