Talk:Swap on microSD

SDCard Partition Methods Thread = Talk on Dual SD Swap Method = See from post 67 - sixwheeledbeast

Latest Version - sixwheeledbeast
swapswitch.sh


 * 1) !/bin/sh


 * 1) Made by sixwheeledbeast, Malkavian, Estel and vi_


 * 1) Setup swap names for script

swap0=/dev/mmcblk0p3 echo $swap0
 * 1) Swap 0 - Backup internal swap location

swap1=/dev/mmcblk1p2 echo $swap1
 * 1) Swap 1 - First Main Swap Location

swap2=/dev/mmcblk1p3 echo $swap2
 * 1) Swap 2 - Second Main Swap Location

swap=`cat /proc/swaps | awk '/dev/ {print $1}'` echo $swap
 * 1) Get Current Swap

s=sudo echo $sudo
 * 1) Go root

banner{ o=org f=freedesktop n=Notifications run-standalone.sh dbus-send --type=method_call \ --dest=$o.$f.$n /$o/$f/$n $o.$f.$n.SystemNoteInfoprint string:"$1" }
 * 1) Setup notification banner

banner "$swap"
 * 1) Print Current Swap Pre

sleep 5

if [ "$swap" = "$swap1" ] ; then nice -20 $s swapon $swap2 nice -20 $s swapoff $swap1 elif [ "$swap" = "$swap2" ] ; then nice -20 $s swapon $swap1 nice -20 $s swapoff $swap2 elif [ "$swap" = "$swap0" ] ; then nice -20 $s swapon $swap1 nice -20 $s swapoff $swap0 else banner "Swap Switch Failed" fi
 * 1) Logic

sleep 5

swappost=`cat /proc/swaps | awk '/dev/ {print $1}'` echo $swappost
 * 1) Get Current Swap

banner "$swappost"
 * 1) Print Current Swap Post

swapswitchejectsd.sh


 * 1) !/bin/sh


 * 1) Made by sixwheeledbeast, Malkavian, Estel and vi_


 * 1) Setup swap names for script

swap0=/dev/mmcblk0p3
 * 1) Swap 0 - Backup internal swap location

swap1=/dev/mmcblk1p2
 * 1) Swap 1 - First Main Swap Location

swap2=/dev/mmcblk1p3
 * 1) Swap 2 - Second Main Swap Location

swap=`cat /proc/swaps | awk '/dev/ {print $1}'` echo $swap
 * 1) Get Current Swap

s=sudo echo $sudo
 * 1) Go root

banner{ o=org f=freedesktop n=Notifications run-standalone.sh dbus-send --type=method_call \ --dest=$o.$f.$n /$o/$f/$n $o.$f.$n.SystemNoteInfoprint string:"$1" }
 * 1) Setup notification banner

banner "$swap"
 * 1) Print Current Swap Pre

sleep 5

if [ "$swap" = "$swap0" ] then banner "Swap on Internal already!" elif [ "$swap" = "$swap1" ] then nice -20 $s swapon $swap0 nice -20 $s swapoff $swap1 elif [ "$swap" = "$swap2" ] then nice -20 $s swapon $swap0 nice -20 $s swapoff $swap2 else banner "Swap Switch Failed" fi
 * 1) Logic

sleep 5

swappost=`cat /proc/swaps | awk '/dev/ {print $1}'` echo $swappost
 * 1) Get Current Swap

if [ "$swappost" = "$swap0" ] then banner "Safe to remove back cover" else sleep 2 banner "ERROR! DO NOT REMOVE BACK COVER" sleep 3 banner "$swappost" fi
 * 1) Print Current Swap Post

Version 1 - Malkavian
swapswitch.sh
 * 1) !/bin/sh


 * 1) Made by Sixwheeledbeast and Malkavian

swap0=/dev/mmcblk0p3 swap1=/dev/mmcblk1p2 swap2=/dev/mmcblk1p3
 * 1) Setup swap names for script
 * 2) Swap 0 - Backup internal swap location
 * 1) Swap 1 - First Main Swap Location
 * 1) Swap 2 - Second Main Swap Location

banner{ o=org f=freedesktop n=Notifications run-standalone.sh dbus-send --type=method_call \ --dest=$o.$f.$n /$o/$f/$n $o.$f.$n.SystemNoteInfoprint string:"$1" }
 * 1) Setup notification banner

old=`cat /proc/swaps | awk '/dev/ {print $1}'`
 * 1) Get Current Swap

if [ "$old" = "$swap0" ] then if [ $RANDOM -lt 16384 ] # RANDOM gives a value from 0 to 32787. We try 50% of probabilities then new="$swap1" else new="$swap2" fi elif [ "$old" = "$swap1" ] then new="$swap2" elif [ "$old" = "$swap2" ] then new="$swap1" else banner "None of the configured swaps found active, revise the configuration. Current active swap (if any): $old" exit 1 fi
 * 1) Logic

swapon $new || \ ( banner "Ops, something failed, cannot swapon $new (so swapoff of $old neither done)" && exit 1 ) nice -20 swapoff $old || \ ( banner "Ops, something failed, swapon of $new done but cannot swapoff $old" && exit 1 ) banner "OK: Swap switched from $old to $new"

swapscriptejectsd.sh


 * 1) !/bin/sh


 * 1) Made by Sixwheeledbeast and Malkavian

swap0=/dev/mmcblk0p3 swap1=/dev/mmcblk1p2 swap2=/dev/mmcblk1p3
 * 1) Setup swap names for script
 * 2) Swap 0 - Backup internal swap location
 * 1) Swap 1 - First Main Swap Location
 * 1) Swap 2 - Second Main Swap Location

banner{ o=org f=freedesktop n=Notifications run-standalone.sh dbus-send --type=method_call \ --dest=$o.$f.$n /$o/$f/$n $o.$f.$n.SystemNoteInfoprint string:"$1" }
 * 1) Setup notification banner

old=`cat /proc/swaps | awk '/dev/ {print $1}'`
 * 1) Get Current Swap

if [ "$old" = "$swap0" ] then banner "Swap on Internal already!" exit 0 else swapon $swap0 || \ ( banner "Ops, something failed, cannot swapon $swap0 (so swapoff of $old neither done)" && exit 1 ) nice -20 swapoff $old || \ ( banner "Ops, something failed, swapon of $swap0 done but cannot swapoff $old" && exit 1 ) fi
 * 1) Logic