Latest revision |
Your text |
Line 3: |
Line 3: |
| See from post 67 - sixwheeledbeast | | See from post 67 - sixwheeledbeast |
| | | |
- | == Swap Switching Scripts == | + | == Scripts == |
| | | |
| === Latest Version - sixwheeledbeast === | | === Latest Version - sixwheeledbeast === |
- | Now uses "EOF gainroot" script, although this causes multiple banner messages in the ejectsd script, not sure how to fix.
| |
- | The first switching script works perfectly and fixes the multiple swapping due to a reorder.
| |
- |
| |
- | swapswitch.sh
| |
- |
| |
- | <pre>
| |
- |
| |
- | #!/bin/sh
| |
- |
| |
- | #Made by sixwheeledbeast, Estel, Malkavian, peterleinchen and vi_
| |
- |
| |
- | # Setup swap names for script
| |
- |
| |
- | ## Swap 0 - Backup internal swap location
| |
- | swap0=/dev/mmcblk0p3
| |
- | echo $swap0
| |
- |
| |
- | ## Swap 1 - First Main Swap Location
| |
- | swap1=/dev/mmcblk1p2
| |
- | echo $swap1
| |
- |
| |
- | ## Swap 2 - Second Main Swap Location
| |
- | swap2=/dev/mmcblk1p3
| |
- | echo $swap2
| |
- |
| |
- | # Go root if not
| |
- | if [ `id -u` != 0 ] ; then
| |
- | exec | sudo gainroot <<EOF
| |
- | exec sh $0 $*
| |
- | EOF
| |
- | exit $?
| |
- | fi
| |
- |
| |
- | # Setup notification banner
| |
- | 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"
| |
- | }
| |
- |
| |
- | # Get and Print Current Swap Pre
| |
- | swap=`cat /proc/swaps | awk '/dev/ {print $1}'`
| |
- | echo $swap
| |
- | banner "$swap"
| |
- |
| |
- | sleep 5
| |
- |
| |
- | #Logic
| |
- | if [ "$swap" = "$swap1" ] ;
| |
- | then
| |
- | nice -20 swapon $swap2
| |
- | nice -20 swapoff $swap1
| |
- | elif [ "$swap" = "$swap2" ] ;
| |
- | then
| |
- | nice -20 swapon $swap1
| |
- | nice -20 swapoff $swap2
| |
- | elif [ "$swap" = "$swap0" ] ;
| |
- | then
| |
- | nice -20 swapon $swap1
| |
- | nice -20 swapoff $swap0
| |
- | sleep 5
| |
- | # Get and Print Current Swap Post
| |
- | swappost=`cat /proc/swaps | awk '/dev/ {print $1}'`
| |
- | banner "$swappost" && exit 1
| |
- | else
| |
- | banner "Swap Switch Failed" && exit 1
| |
- | fi
| |
- | #End of Logic
| |
- | </pre>
| |
- |
| |
- | swapswitchejectsd.sh
| |
- |
| |
- | <pre>
| |
- |
| |
- | #!/bin/sh
| |
- |
| |
- | ##Made by sixwheeledbeast, Estel, Malkavian, peterleinchen and vi_
| |
- |
| |
- | # Setup swap names for script
| |
- |
| |
- | ## Swap 0 - Backup internal swap location
| |
- | swap0=/dev/mmcblk0p3
| |
- |
| |
- | ## Swap 1 - First Main Swap Location
| |
- | swap1=/dev/mmcblk1p2
| |
- |
| |
- | ## Swap 2 - Second Main Swap Location
| |
- | swap2=/dev/mmcblk1p3
| |
- |
| |
- | # Setup notification banner
| |
- | 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"
| |
- | }
| |
- |
| |
- | # Get and Print Current Swap Pre
| |
- | preswap=`cat /proc/swaps | awk '/dev/ {print $1}'`
| |
- | banner "$preswap"
| |
- | sleep 5
| |
- |
| |
- | #Logic
| |
- | if [ "$preswap" = "$swap0" ];
| |
- | then
| |
- | banner "Swap on Internal already" && exit 1
| |
- | elif [ "$preswap" = "$swap1" ];
| |
- | then
| |
- | # Go root if not
| |
- |
| |
- | if [ `id -u` != 0 ] ; then
| |
- | exec | sudo gainroot <<EOF
| |
- | exec sh $0 $*
| |
- | EOF
| |
- | exit $?
| |
- | fi
| |
- | nice -20 swapon $swap0
| |
- | nice -20 swapoff $swap1
| |
- | sleep 3
| |
- | swappostswitchone=`cat /proc/swaps | awk '/dev/ {print $1}'`
| |
- | banner "$swappostswitchone"
| |
- | sleep 2
| |
- | banner "Safe to remove back cover" && exit
| |
- | elif [ "$preswap" = "$swap2" ];
| |
- | then
| |
- |
| |
- | # Go root if not
| |
- |
| |
- | if [ `id -u` != 0 ] ; then
| |
- | exec | sudo gainroot <<EOF
| |
- | exec sh $0 $*
| |
- | EOF
| |
- | exit $?
| |
- | fi
| |
- | nice -20 swapon $swap0
| |
- | nice -20 swapoff $swap2
| |
- | swappostswitchtwo=`cat /proc/swaps | awk '/dev/ {print $1}'`
| |
- | banner "$swappostswitchtwo"
| |
- | sleep 2
| |
- | banner "Safe to remove back cover" && exit
| |
- | else
| |
- | banner "Swap Switch Failed"
| |
- | sleep 2
| |
- | banner "DO NOT REMOVE BACK COVER - Please check swaps manually via terminal" && exit 2
| |
- | fi
| |
- |
| |
- | </pre>
| |
- |
| |
- | === Version 1 - sixwheeledbeast ===
| |
| | | |
| swapswitch.sh | | swapswitch.sh |
Line 394: |
Line 242: |
| fi | | fi |
| </pre> | | </pre> |
- |
| |
- | == Information on Starting Swap on SD at bootup ==
| |
- |
| |
- | Upstart format - new file in event.d
| |
- |
| |
- | etc/event.d/relocateswap
| |
- | <pre>
| |
- | description "Micro SD Swap Location on Startup"
| |
- | author "sixwheeledbeast"
| |
- |
| |
- | console output
| |
- |
| |
- | start on started rcS-late
| |
- |
| |
- | script
| |
- | swapon /dev/mmcblk1p2
| |
- | sleep 10
| |
- | swapoff /dev/mmcblk0p3
| |
- | end script
| |
- |
| |
- | </pre>
| |
- |
| |
- | ==Original script from main page==
| |
- | This script can be run via [[Terminal]] or using an application like [[Queen BeeCon Widget]].
| |
- |
| |
- | It is for refreshing swap if main swap space is on Micro SD Partition 2.
| |
- |
| |
- | run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"Start Swap Refresh" uint32:0 string:"OK"; sudo swapon /dev/mmcblk0p3 ; sudo swapoff /dev/mmcblk1p2 ; run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Swapping Back to Main Swap on SD..." ; sudo swapon /dev/mmcblk1p2 ; sudo swapoff /dev/mmcblk0p3 ; run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteDialog string:"Swap Refresh Complete" uint32:0 string:"OK"
| |
- |
| |
- | This script can be modified to suit different swap locations as required.
| |