Setting swapiness is how I can deal with a recurrence but it will not
flush current swap. And I can not shut down any process to perform
swap off. :(
On 11/4/10, Eric Shubert <ejs@shubes.net> wrote:
> 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'
>
# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
c) Set up a Linux swap area:
# mkswap /swapfile1
d) Activate /swapfile1 swap space immediately:
# swapon /swapfile1
e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
# vi /etc/fstab
Append following line:
/swapfile1 swap swap defaults 0 0