[K12OSN] Deleting Swap Files

Petre Scheie petre at maltzen.net
Fri Mar 11 19:35:20 UTC 2005



Eric Harrison wrote:
> On Thu, 10 Mar 2005, Shawn Powers wrote:
> 
>> On Mar 10, 2005, at 1:33 PM, Eric Harrison wrote:
>>
>>> /usr/sbin/tmpwatch --verbose --test 720 /var/opt/ltsp/swapfiles
>>
>>
>> This showed a whole ton of files that would be deleted.  Who knew, a 
>> program (tmpwatch) written specifically for my situation.  ;o)
>>
>> Thanks Eric, I'll run that after 3PM without the test & verbose.
>>
>> You da man,
>> -Shawn
> 
> 
> This is slightly riskier/trickier than I had hoped. I enabled 
> USE_NFS_SWAP and booted a test box with 16M of ram. I let it set for an 
> hour and then ran tmpwatch telling it to delete used files over an hour 
> old.
> 
> It deleted the swap file, causing the terminal to crash. It had to be 
> power-cycled before it would start X.
> 
> I could always cause a problem by using touch to muck with the date
> stamps:
> 
>     touch -d "01/01/01 01:01:01" /var/opt/ltsp/swapfiles/192.168.0.253.swap
> 
> 
> The fuser command doesn't see that the file is open, as such adding the 
> --fuser flag to tmpwatch does not help.
> 
> The most conservative setting I can come up with is:
> 
>     /usr/sbin/tmpwatch --ctime --atime --mtime 720 /var/opt/ltsp/swapfiles/
> 
> This should only cause a problem if:
> 
>  * your server's clock is suddenly set more than a month in the future,
>    and is not fixed before the /etc/cron.daily/ scripts run
> 
> or
> 
>  * you have a terminal that has been running for more than a month, never
>    used swap, had the swap file deleted, and then need some swap space
> 
> or
> 
>  * some other problem I have not thought of yet
> 
> 
> In any case this should be fairly rare. But then so is running out of 
> server
> space because of unused swap files.
> 
> There is probably a way to work-around this in any case.
> Maybe something as simple as:
> 
>     for terminal in `showmount | grep -v '/'`
>     do
>         if [ -f /var/opt/ltsp/swapfiles/${terminal}.swap ]
>         then
>             touch /var/opt/ltsp/swapfiles/${terminal}.swap
>         fi
>     done
>     /usr/sbin/tmpwatch --ctime --atime --mtime 720 /var/opt/ltsp/swapfiles/
> 
> 
> I'm going to sleep on it before I build a test package. In the meantime,
> hopefully someone will come up with a bright idea on how to do this
> safely ;-)
> 
> -Eric
> 
Perhaps I don't understand the process, but shouldn't there be a finite number of files 
(one?) for each client?  In which, in Shawn's case, clients must have been creating 
multiple swap files (a new one each time the client is booted?).  And if that's the 
case, is there something in the name of the swapfile that identifies which client it 
belongs to?  And even if there isn't, there shouldn't be, at any given moment, more swap 
files than total possible clients, right?  So, if you have 30 total possible clients, 
could you remove everything but the 30 most recently accessed files?  Just my $.02.

Petre




More information about the K12OSN mailing list