S09swap

Post Reply
evolution536
Posts: 3
Joined: Mon May 30, 2011 10:14 am

S09swap

Post by evolution536 » Mon May 30, 2011 10:22 am

Hello,

I have been busy with my NS, i have it hacked, with telnet active. It's a low RAM device, and this often results in my samba or proftpd in being killed by the OOM when i am copying something.

I found the kernel parameters in /proc/sys/vm, swappiness, min_free_kbytes, and memory_overcommit. When i changed those, the swappiness increased, and my process wasnt often being killing anymore. However, these values were being restored to original when the device reboots.

I put the commands to change those values in the S09swap script, to activate them at bootup. That worked a bit for me, as the values still were changed at every bootup. Now somehow, i think by pressing a wrong button, the S09swap script went empty. the swapfile isnt even being mounted anymore, and my NS is kind of screwed, as the memory killer is busy at any time.

Is there someone who can post the original S09swap script?

p.s. I tried to install sysctl via ipkg (ipkg install busybox), but my ipkg returned a wget error in any command i tried. So far i didnt manage to get programs via ipkg.

Thanks in advance!

Mijzelf
Posts: 6194
Joined: Mon Jun 16, 2008 10:45 am

Re: S09swap

Post by Mijzelf » Mon May 30, 2011 6:07 pm

Code: Select all

#!/bin/sh
# Begin $rc_base/init.d/swap - Swap Control Script

# Written by Gerard Beekmans  - gerard@linuxfromscratch.org

. /etc/sysconfig/rc
. $rc_functions

case "$1" in
        start)
                echo "Activating all swap files/partitions..."
                swapon -a
                if [ x"$?" = x"1" ]
                then
                        swapoff -a
                        for swapdev in `cat /etc/fstab | grep swap | awk '{print $1}'`
                        do
                                mkswap $swapdev                 
                                swapon $swapdev
                        done
                fi
                evaluate_retval
                ;;

        stop)
                echo "Deactivating all swap files/partitions..."
                swapoff -a
                evaluate_retval
                ;;

        restart)
                $0 stop
                sleep 1
                $0 start
                ;;

        *)
                echo "Usage: $0 {start|stop|restart|status}"
                exit 1
                ;;
esac

# End $rc_base/init.d/swap

evolution536
Posts: 3
Joined: Mon May 30, 2011 10:14 am

Re: S09swap

Post by evolution536 » Tue May 31, 2011 11:52 am

thank you very much Mijzelf.

That was the script i needed.

Post Reply