Editing Talk:Swap on microSD

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 6: Line 6:
=== 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

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)