[K12OSN] Deleting Swap Files

Eric Harrison eharrison at mail.mesd.k12.or.us
Fri Mar 11 23:55:15 UTC 2005


Jim McQuillan wrote:
> Eric,
>
> You could use "showmount -a" to show if the workstation has the
> /var/opt/ltsp/swapfiles directory mounted.
>
> Jim.

I tried that at first, but found that there were a lot of stale entries.
   Since the terminals never umount the server, it looks like their
entries are never flushed out of mountd. From the mountd man page: (note
that
"showmount -a" matches /var/lib/nfs/rmtab on the servers I checked)

   For every mount request received from an NFS client,  rpc.mountd  adds
   an  entry  to  the  /var/lib/nfs/rmtab file. When receiving an unmount
   request, that entry is removed.

   However, this file is mostly ornamental. One, the client can  continue
   to  use the file handle even after calling rpc.mountd 's UMOUNT proce-
   dure. And two, if a client reboots without notifying  rpc.mountd  ,  a
   stale entry will remain in rmtab.


If we use stale data to figure out what is in use, we'll end up skipping
the very stale files we want to delete. It would only be cleared out
whenever the server happens to be rebooted.

Perhaps the best option would be to just automatically "rm -f
/var/opt/ltsp/swapfiles/*.swap" whenever the server boots....

-Eric

> On Fri, 11 Mar 2005, Eric Harrison wrote:
>
>
>>Eric Harrison wrote:
>>
>>>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 ;-)
>>
>>After sleeping on it, chatting with Shahms King a while, and then taking
>>a long lunch, here is the best I can come up with:
>>
>>
>>cd /var/opt/ltsp/swapfiles/
>>for ip in `ls *.swap 2>/dev/null | sed s/.swap$//g`
>>do
>>   netstat -nap 2>/dev/null | grep ${ip}: >/dev/null && touch ${ip}.swap
>>   ping -c 1 -w 10 ${ip} &> /dev/null && touch ${ip}.swap
>>done
>>/usr/sbin/tmpwatch --ctime --atime --mtime 168 /var/opt/ltsp/swapfiles/
>>
>>
>>
>>
>>This would prevent a swap file from being deleted if any one of the
>>following were true:
>>
>>  * the terminal had written to the swap file sometime in the last week
>>  * the terminal had a tcp connection to the server in the last week
>>  * the terminal could be pinged sometime in the last week
>>
>>
>>The corner-case in this scenario is fairly small. All of the following
>>would have to true for an active swap file to be deleted:
>>
>>  * the terminal would have to be configured to use a different server
>>    for NFS_SWAP than it uses for its XDM connection, the default is
>>    that the NFS_SWAP server & the XDM server are the same.
>>  * pings would have to be disabled on the network
>>  * the terminal did not modify the swap file in the previous week
>>
>>
>>That seems sane enough for me. But then I don't use NFS_SWAP and don't
>>have to hear people scream when their terminals randomly crash ;-)
>>
>>Any other sanity checks I could add in?
>>
>>-Eric
>>
>>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/k12osn/attachments/20050311/f1752c39/attachment.sig>


More information about the K12OSN mailing list