maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   [DISCUSS] SDCard Swap Partition Methods.. (https://talk.maemo.org/showthread.php?t=84296)

peterleinchen 2012-07-12 12:06

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Quote:

Originally Posted by sixwheeledbeast (Post 1236153)
With ereswap IINM you can only have a primary and a temporary swap space.
I wish to have two swaps which I can "flip/flop" to.

I do not get your flip/flop idea.
If you enable another flop location and disbable the flip location, all data will be moved from flip to flop.
Enabling both swaps with same priority does not make sense.
Nad enable them with different priority even less, as only higher priority will be used (except you reach 800MB swap usage, very unlikely).

Only advantage I see is fully omitting swap space (wear) on eMMC.

malkavian 2012-07-12 15:19

Re: [DISCUSS] SDCard Swap Partition Methods..
 
With ereswap you have 2 swap partitions, one on eMMC for backup and one on the SD card for main usage. When ereswap refresh the swap it put on the backup, put off the main and then backwards, put on the main, and put of the backup. These are 4 steps and 2 data movings, using backup swap for the transition.

If you would have 3 swap partitions you would have eMMC one for backup (only if you haven't the SD card or it's broken), and two in the SD card to alternate. When you want to refresh you just put on the swap2 and put off the swap1, and thats all. (Next swap refresh you will put off swap2 and put on swap1). Backup eMMC swap is never used (saving of damage his cells and damaging SD ones) and you only need 2 steps and one data moving. And 2 swap partitions share the damage to sd cells.

I prefer the second method and I will try to modify ereswap to use it. I hope Estel likes the modification and integrates it in ereswap. Maybe could be make an option to use one or two swap partitions on SD Card, as user wants.

OMOIKANE 2012-07-12 18:57

Re: [DISCUSS] SDCard Swap Partition Methods..
 
I have N900 with swap on sd card partition. Swap on emmc is disabled.
And i have a problem with some osso applications. RSS, for example, after returning from microb, refreshing to main window, contacts refreshing to top of list after call. Both programs showing "<app name> - resuming" on the top. With emmc swap enabled glitch disappears. What to do?

peterleinchen 2012-07-12 19:49

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Quote:

Originally Posted by malkavian (Post 1236595)
With ereswap you have 2 swap partitions, one on eMMC for backup and one on the SD card for main usage. When ereswap refresh the swap it put on the backup, put off the main and then backwards, put on the main, and put of the backup. These are 4 steps and 2 data movings, using backup swap for the transition.

Ah okay. Now I see ;)
I was not aware of second moving back, as I just have my SD swap as higher priority and only disf/enable it. So all data is moved once to eMMC and then read /forgotten from there and all new swap is located again on SD.
Maybe not the best approach, but for me it works nicely.

But two swaps on SD is also good approach to save eMMC wear.
Maybe I add another swap file ...

sixwheeledbeast 2012-07-12 20:35

Re: [DISCUSS] SDCard Swap Partition Methods..
 
2 Attachment(s)
Quote:

Originally Posted by peterleinchen (Post 1236724)
Ah okay. Now I see ;)

But two swaps on SD is also good approach to save eMMC wear.
Maybe I add another swap file ...

Sorry if I didn't explain in the best way.

I could do with a little help with the scripts I am making to complete the rest of my idea in post 67.

Using some of the source of ereswap I have two scripts one for Swapping and one for Switching to Internal (to eject SD safely) but I can't work out how to get the current swaps and use them in the script.

Bit new to the more involved scripting.

If they work it would be possible to make a small app or be incorporated with ereswap somehow.

peterleinchen 2012-07-12 20:48

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Quote:

Originally Posted by sixwheeledbeast (Post 1236743)
Sorry if I didn't explain in the best way.

I think it was me dumbhead here ;)

Sorry no time to look in your scripts, but
cat /proc/swaps
should give you info what swap is enabled...

sixwheeledbeast 2012-07-12 20:52

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Quote:

Originally Posted by peterleinchen (Post 1236753)
I think it was me dumbhead here ;)

cat /proc/swaps
should give you info what swap is enabled...

Ok ta ;)

Using
Code:

cat /proc/swaps | awk '/dev/ {print $1}'
output in a terminal is ok but not in the scripts, tried a few other ways too. will keep researching.

peterleinchen 2012-07-12 21:10

Re: [DISCUSS] SDCard Swap Partition Methods..
 
You want output to store in a variable?

Normally I use version c
Code:

cat /proc/swaps | awk '/dev/ {print $1}'
awk '/dev/ {print $1}' /proc/swaps

a=cat /proc/swaps | awk '/dev/ {print $1}'
echo $a
b=awk '/dev/ {print $1}' /proc/swaps
echo $b

c=`cat /proc/swaps | awk '/dev/ {print $1}'`
echo $c
d=$(awk '/dev/ {print $1}' /proc/swaps)
echo $d

Or what?

malkavian 2012-07-12 21:26

Re: [DISCUSS] SDCard Swap Partition Methods..
 
@peterleinchen So when you put off SD swap, all data there is moved to eMMC swap, and afterwards when you put on SD swap, old data is on eMMC one and new data is writed to SD one.

I see a problem: eMMC will be used to have the old data after the refresh, and while your programs need that old data to be readed and loaded in RAM, you will be using some of the eMMC, so your mobile will be a bit slower (remember we use swap on SD for never using eMMC for swap and at the same time data from /home or /MyDocs (in eMMC too), soo we get less stress in eMMC). It's not a big problem, but well, would be better if you only use SD always.

vi_ 2012-07-12 21:33

Re: [DISCUSS] SDCard Swap Partition Methods..
 
This toggles between SD/eMMC:

Code:

#!/bin/sh
#swapswap
current_swap=$( cat /proc/swaps | awk '/mmcblk/ {print $1}' | cut -d "k" -f2 | cut -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
        nice -20 swapon $swapmicro
        nice -20 swapoff /dev/mmcblk0p3    fi
#echo "swap is on sd"
elif [ "$current_swap" = "1" ]; then
    nice -20 swapon /dev/mmcblk0p3
    nice -20 swapoff $swapmicro
#echo "swap is on emmc"
fi

Run this at 4AM or whenever your n900 is out of action:
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
    fifi



All times are GMT. The time now is 15:51.

vBulletin® Version 3.8.8