View Single Post
Posts: 1,680 | Thanked: 3,685 times | Joined on Jan 2011
#164
oooh boy, swap scripts! here is my swapswap script.

This script simply swaps the swap from one drive to the other. That means to 'refresh' the swap you would run it twice. The script is also able to automatically figure out which partition on the sdcard is the swap. It is partially based on a script suggested by 'whitewolf' in the 'swap on sd' thread.

Code:
#!/bin/sh
#swapswap
current_swap=$( cat /proc/swaps | awk '/mmcblk/ {print $1}' | cut -d "k" -f2 ut -c1)
drivelist=$(sfdisk -lnd /dev/mmcblk1)
swapmicro=$(echo "$drivelist" -n | grep Id=82 | awk '/mmcblk1/ {print $1}')

if [ "$current_swap" = "0" ]; then
        if [ "$swapmicro" ]; then
            swapon $swapmicro
            swapoff /dev/mmcblk0p3
        fi
#echo "swap is on sd"
elif [ "$current_swap" = "1" ]; then
        swapon /dev/mmcblk0p3
        swapoff $swapmicro
#echo "swap is on emmc"
fi

ya follow?



I have the following script run at 0330 to refresh the swap space.

Code:
#!/bin/sh
#check if device is not in use, if so swapswap!
brightness=$(cat /sys/class/backlight/acx565akm/brightness)
keyboard=$(cat /sys/devices/platform/gpio-switch/slide/state)

if [ "$brightness" == "0" ]; then
        if [ "$keyboard" == "closed" ]; then
                echo "/opt/scripts/swapswap.sh" | root
                echo "/opt/scripts/swapswap.sh" | root
        fi
fi
This checks to see if the device is in use (unlikly@0330. However you never know, I like my scripts to be bullet proof). If not, then it calls swapswap twice once to move it over, once to move it back.
__________________
N900: One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die.
 

The Following 7 Users Say Thank You to vi_ For This Useful Post: