[K12OSN] Deleting Swap Files
Eric Harrison
eharrison at mail.mesd.k12.or.us
Fri Mar 11 04:01:35 UTC 2005
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
More information about the K12OSN
mailing list