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)

BertvanDorp 2012-05-21 16:11

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

Originally Posted by peterleinchen (Post 1210245)
I am worried about the instant reboots I experience when enabling ramzswap. Happens sometimes, not always, but in a startup script?

Then the easiest solution for newbies is package swapset.
Even nobody will check sources ("dpkg -x *.deb ."), but just install ...

@Bert

already done, see package swapset
(except this does not work for swap files, just partitions)

You see, this is where we think differently. Installing SwapSet doesn't exactly do what I listed, now does it? It only enables some undocumented command-line interface.

I'm getting really tired of the whole educate-yourself mentality. I mean, really, if it was that achievable, wouldn't you see more users doing what's needed?

Anyway, off to Samsung SGS3, wanted to contribute for one last time..

Estel 2012-05-21 16:19

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Amount of written bytes should be ok, although You may want to use 700 MB instead of 768 - to reswap it before fragmentation hit You, not after.

BTW, I'm currently working on providing solution to reswap and few other things to repositories.

/Estel

woody14619 2012-05-21 16:48

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

Originally Posted by BertvanDorp (Post 1210273)
I'm getting really tired of the whole educate-yourself mentality. I mean, really, if it was that achievable, wouldn't you see more users doing what's needed?

Anyway, off to Samsung SGS3, wanted to contribute for one last time..

Wow...

This is the root of the problem I've seen in my own country and countless others around the planet. Why put for the effort to learn anything at all. Better to go buy something where all the thinking and learning was done for you, so you can simply click a button and it does one thing you want (while losing the ability to 50 other things you may want to do but don't even consider an option).

Tired of the "whole educate-yourself mentality"? I'm tired of the mentality that you shouldn't have to think at all for yourself. Or that education is bad or damaging in some way.

Our political process just had a slew of would-be leaders bad-mouthing college education, claiming it leads to "liberal thinking" and other "evils". (This despite every one of them being a college graduate.)

Btw: Whining is not a contribution. Remaining uneducated is not a contribution. Encouraging others to remain uneducated is not a contribution.

Good luck with your SGS3. Enjoy your locked-in garden-fenced device if you can. But please don't insist that the rest of us live in the little kept zoo cell you call home.

michaaa62 2012-05-21 18:32

Re: [DISCUSS] SDCard Swap Partition Methods..
 
For starters you might want to read the wiki article about repartitioning of the emmc http://wiki.maemo.org/Repartitioning_the_flash . Although it was written for increased space in optfs, the technique of partitioning, editing system files is essential to get space for an external swap partition.
Try to digest this content, google for some more info, or ask specific questions here in the forum, may be in a separate thread.
I am sure, you will get help along the way.

peterleinchen 2012-05-21 18:53

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

Originally Posted by BertvanDorp (Post 1210273)
You see, this is where we think differently. Installing SwapSet doesn't exactly do what I listed, now does it? It only enables some undocumented command-line interface.

I'm getting really tired of the whole educate-yourself mentality. I mean, really, if it was that achievable, wouldn't you see more users doing what's needed?

Anyway, off to Samsung SGS3, wanted to contribute for one last time..

Normally I never answer to such posts.
BUT: I do not get it all! What is your thinking here?

Quote:

but I'm simply not able to implement this right now.
Your bad.

Quote:

Converting this into a package ('app' in regular-user words) would involve no risk for the regular user, and help out, right?
Exactly what swapset is.

Quote:

The steps would be:
1. create file, name ...
2. use 'swapon ...' to test
3. run [thing] to disable unmounting on removing cover
4. do [thing] to include both measures in bootloop
5. [...]
6. profit!
7. some incredible hero converts this into an app, and gets donations, thanks, and so on
Again, read the sources of swapset and here you find all the answers.

@Bert
Have fun with your malicious code running dumb "smart phone".

BertvanDorp 2012-05-21 19:21

Re: [DISCUSS] SDCard Swap Partition Methods..
 
So, ok, I was out of line and I'm sorry for upsetting you guys. I had a small laugh when I was reading the comments; I can remember countless occasions where I responded in quite the same fashion. :rolleyes:

The thing I was pointing at - and I didn't get across - was that, in order for all of this coding magic, skill and effort to help create a workable user experience for the regular user (noobs, in other words), it would really help out if best practices where to be gathered and to be put into safe-to-use packages. I think Swappolube and CSSU are key examples of this, and the thing I wanted to discuss is how we could get to such a thing. So, really, I was trying to help out. The point that upset me, is the short and oh-so-elite answer: 'well, this thing here does that, go enjoy' while, at that point, this didn't seem to meet the thing I was trying to contribute to/achieve.

-- short offtopic thing on education and mentality: I'm a Mechanical Engineer, trying to work on a sustainable energy future. I'm involved in political organisations, do some volunteer work, active member of our local Church and I'm this guy really keen on discussing Linux and open-source at birthday parties. So I think you guys would actually, you know, like me, but that's something you sometimes just can't get across in these internet discussions..

So, back to the topic. I would like to create a guide for getting swap-to-microSD to work, achievable for the average user, of which I am a prime example. I'm starting from a Windows 7 environment, the wiki on repartitioning, swapset and will try to create this.

TL;DR: apologies, and I'll try to create this guide myself.

peterleinchen 2012-05-21 19:29

Re: [DISCUSS] SDCard Swap Partition Methods..
 
And you should have all the answers almost already in here.
If you still have questions, we will help you.

BertvanDorp 2012-05-21 21:49

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Read throught the sources for SwapSet and it's a great tool - was actually disappointed to find out I already had SwapSet installed, and thus I was already enjoying compcache on every start of the device ..

So, I'm trying to use Windows 7 or the N900 to do the repartitioning of the microSD. I have not been able to find a guide doing this, and I'm hoping to offer a solution without going the LiveCD->Gparted route. So, I'm trying to do this on the N900 using a script. That script could possibly be incorporated in SwapSet, and on installation or update the user could be requested whether or not the user wanted to use the micro-SD for this. I'm thinking something like: {PSEUDO-CODE ALERT}
Code:

If not swap_found_on_SD
    offer question /* want to repartition the SD to create a swap partition yes/no
  if yes
    check for availability
    repartitioning
  end if
end if
swapset startup

So it seems this could be done using fdisk and rootsh. I'll try and write a proposal script for this later on. Would size=256mb be sufficient, or should this be larger?

Next topic, about unmounting the Swap partition before the whole microSD gets unmounted - what's the best route here? I was thinking either use dbus or any other event thing to unmount the swap and re-prioritize the swap, or to alter the behaviour so that the swap doesn't get unmounted. This last solution would require loads of big-text red lines screaming not to release the microSD before turning off the device. However, there's mixed reports on this issue, as sulu pointed out that the partition does not get unmounted when the cover is taken off. Anybody?

reinob 2012-05-22 09:10

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

Originally Posted by BertvanDorp (Post 1210461)
Next topic, about unmounting the Swap partition before the whole microSD gets unmounted - what's the best route here? I was thinking either use dbus or any other event thing to unmount the swap and re-prioritize the swap, or to alter the behaviour so that the swap doesn't get unmounted. This last solution would require loads of big-text red lines screaming not to release the microSD before turning off the device. However, there's mixed reports on this issue, as sulu pointed out that the partition does not get unmounted when the cover is taken off. Anybody?

I have swap on the SD card. I just pulled the cover and my SD partitions got unmounted EXCEPT for the swap (which is not really mounted).

I guess, but I cannot confirm, that when pulling out the cover any mounted partition (perhaps even only VFAT, but I don't know) gets unmounted, but that's all.

Swap is by definition not a mounted partition, so nothing happens.

Obviously, if you do pull the CARD with swap on it you get an instant crash.

Estel 2012-05-22 09:38

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Hm, strange. I would say I remember people saying that they've tried removing cover with swap on microSD and seeing instant crash... Well, either they've lied, or there is inconsistency between device's behavior.

/Estel

Estel 2012-05-22 13:48

Re: [DISCUSS] SDCard Swap Partition Methods..
 
As promised, I've uploaded tool to fight swap fragmentation to extras-devel (in fact, doing more than that). For more info and/or discussion about it, see:
http://talk.maemo.org/showthread.php?t=84413

/Estel

peterleinchen 2012-05-22 21:35

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

Originally Posted by reinob (Post 1210637)
I have swap on the SD card. I just pulled the cover and my SD partitions got unmounted EXCEPT for the swap (which is not really mounted).

I guess, but I cannot confirm, that when pulling out the cover any mounted partition (perhaps even only VFAT, but I don't know) gets unmounted, but that's all.

Swap is by definition not a mounted partition, so nothing happens.

Obviously, if you do pull the CARD with swap on it you get an instant crash.

I wanted to know for me (using swap file on vfat partition).
Even I may use lazy umount to make the partition unreadable to N900, I do not get USB mass mode available. So I need modified osso-mmc-umount (removing loop devices) to get the partition really accesible and mass storage mode available.
So I assumed same as reinob, that removing back cover will also work.
BUT, indeed I do get an instant crash. :(

So, Estel, here is one occurance.
Maybe I do need the magnet glued? But hey, I do know not to do so ;) (and I will never throw it to the floor, so the back cover will spring open)

reinob 2012-05-23 07:44

Re: [DISCUSS] SDCard Swap Partition Methods..
 
@peterleinchen,

Well you can't have everything in this world. There no way you can possibly allow a PC exclusive access to a partition while the N900 uses a chunk of that partition as memory.

So either you use SSH/NFS/CIFS/whatever or you create a separate partition for swap.

peterleinchen 2012-05-23 08:07

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

Originally Posted by reinob (Post 1211212)
@peterleinchen,

Well you can't have everything in this world.

But I do want and still trying ...
;)

No serious, it is absolutely clear. Thanks for reply anyway.
But I just wanted to test it. And there are posts about people able to mount simultaneosly (mostly using ubuntu?).

I just wanted to check wether this mass-storage-not-possible possibly also made my back cover removing stable. But: no. For my HW the SD gets completely disabled, it seems.
And for SD unmounting I already have a script.

Estel 2012-05-23 09:15

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Maybe just vfast partitions are cut-off? It seems, that people using native linux partition on SD and/or any ext, doesn't get it unmounted during cover removal.

as for glueing magnet, I'm using this for ages and haven't noticed any regressions. I'm just able to take cover out at any time, which suit me, as I've glued a cut-off part of microSD box (this one with small holder for SD) and I hold backup microSD inside cover.

/Estel

sixwheeledbeast 2012-05-24 20:31

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

Originally Posted by vi_ (Post 1207323)
It believe it is entirely possible to create a 'swapon SD/swapoff SD' entry in power menu 'systemui.xml' just by adding a few lines just like phone/tablet mode button thing.

Is there any more information on these few lines of code?
Thanks

vi_ 2012-05-24 21:27

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Unfortunately not. |The workings of Systemui.xml is completely undocumented.

However if you study the code of tablet/phone mode button you will see it is entirely possible to run scripts/dbus calls directly from systemui.xml. Also you can relay the status of things with icons etc as per a file, again see tablet/phone mode button.

BIG FAT WARNING!!

If you screw up systemui.xml your N900 WILL become unbootable until you undo whatever you messed up. This can be done with backupmenu/rescue OS/rescue console.

reinob 2012-06-28 11:07

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

Originally Posted by reinob (Post 1210637)
I have swap on the SD card. I just pulled the cover and my SD partitions got unmounted EXCEPT for the swap (which is not really mounted).

I guess, but I cannot confirm, that when pulling out the cover any mounted partition (perhaps even only VFAT, but I don't know) gets unmounted, but that's all.

Swap is by definition not a mounted partition, so nothing happens.

Obviously, if you do pull the CARD with swap on it you get an instant crash.

Just one additional comment: just a few minutes ago I happened to pull the back over of my N900 and it instantly rebooted.

I'm seriously getting tired of a lot of Maemo-crap that happens to be loaded in our loved N900s. Thanks to @Estel I have my third N900 which I'm basically r4aping by removing lots of preinstalled stuff and cleaninng up the boot process a bit. I will see if I can completely get rid of ke-recv and related GNOMEish-Windows-ish-user-is-too-dumb-to-do-this-by-himself stuff.

My aim is to make a minimal Maemo (I might even remove hildon desktop) which I can then "easily" move to the eMMC (and use U-boot to boot it) and then pack everything in a flashable image.

Anyway, next step is ke-recv.

michaaa62 2012-06-28 13:21

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

Originally Posted by reinob (Post 1228535)
Just one additional comment: just a few minutes ago I happened to pull the back over of my N900 and it instantly rebooted.

I'm seriously getting tired of a lot of Maemo-crap that happens to be loaded in our loved N900s. Thanks to @Estel I have my third N900 which I'm basically r4aping by removing lots of preinstalled stuff and cleaninng up the boot process a bit. I will see if I can completely get rid of ke-recv and related GNOMEish-Windows-ish-user-is-too-dumb-to-do-this-by-himself stuff.

My aim is to make a minimal Maemo (I might even remove hildon desktop) which I can then "easily" move to the eMMC (and use U-boot to boot it) and then pack everything in a flashable image.

Anyway, next step is ke-recv.

Very interesting! Please keep informing on your proceedings.

sixwheeledbeast 2012-07-04 22:31

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Would there be any benefits in having 2 swap spaces on Micro SD?
Leaving the standard swap space as backup (for no card inserted).
Maybe use cron to Swap between the SD Swaps at night?

Getting a 64GB card soon and going to partition it up to get stuff off the phones memory (mainly Music and Docs). Looking for best way to partition off and sizes.

sulu 2012-07-05 06:52

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

Originally Posted by sixwheeledbeast (Post 1232062)
Would there be any benefits in having 2 swap spaces on Micro SD?
Leaving the standard swap space as backup (for no card inserted).
Maybe use cron to Swap between the SD Swaps at night?

That depends on what you consider to be a benefit.
If you don't need these additional 768MB on your emmc it doesn't hurt to keep the stock swap partition anyway.
Changing between swap partitions via a cron essentially does what Estel's ereswap does if you set it up to automatically switch the partition, so it has the same pros and cons:
pro: You get a "fresh" swap every morning.
con: Each copy of the swap contents means another writing process on a fairly limited amount of flash cells, eventually decreasing the cell's lifetime. But I don't think that's an issue unless you intend to keep your N900 for a decade or so.

reinob 2012-07-05 07:06

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

Originally Posted by michaaa62 (Post 1228579)
Very interesting! Please keep informing on your proceedings.

Well, the time I can dedicate to this is severly limited :), but at the moment I have removed a whole bunch of stuff from a standard PR1.3 install and copied the whole rootfs to a folder under /home (which I partitioned to be 8GB).

Now I'm working on making a version of KP50 with many modules built-in so that it can boot via U-boot without needing an initrd or anything from the NAND chip.

That'll take some time though..

sixwheeledbeast 2012-07-05 18:05

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

Originally Posted by sulu (Post 1232191)
con: Each copy of the swap contents means another writing process on a fairly limited amount of flash cells, eventually decreasing the cell's lifetime. But I don't think that's an issue unless you intend to keep your N900 for a decade or so.

This is why I am thinking of using only Micro SD swap but two of them. I do plan to reduce the wear on the N900's flash in doing this.

If there both on the SD, I only have to switch between the swaps (swap2 on, swap1 off) compared to a full reswap (swap2 on, swap1 off, swap1 on then swap2 off).

On my 64Gb card I am thinking 2x 800Mb swap spaces, 5Gb Document partition and whatever's left for a Music partition.

Can anybody see any issues I may come across with this?

With music on the card I am hoping for smooth multi tasking while playing music under heavy load.

misiak 2012-07-06 06:56

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

Originally Posted by sixwheeledbeast (Post 1232517)
On my 64Gb card I am thinking 2x 800Mb swap spaces, 5Gb Document partition and whatever's left for a Music partition.

Can anybody see any issues I may come across with this?

With music on the card I am hoping for smooth multi tasking while playing music under heavy load.

You will reduce wear, but having files on microsd and swap on microsd it can still lag as hell (same situation as swap on internal flash + files on internal flash), as the microsd controller will have conflicts on writing/reading to swap and files partition (I hope you understand what I mean).

sulu 2012-07-06 07:56

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Music (read-only) and documents (small files, very few writes) shouldn't cause much trouble if they are on the SD card with the swap partition. Of course there may still be conflicts but the device should be able to handle them.
I have swap and (mostly) music on my SD card and almost never experience any hickups.

sixwheeledbeast 2012-07-06 21:52

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

Originally Posted by misiak (Post 1232764)
(I hope you understand what I mean).

This was exactly what I was getting at as reguard to issues.

Quote:

Originally Posted by sulu (Post 1232776)
Music (read-only) and documents (small files, very few writes) shouldn't cause much trouble if they are on the SD card with the swap partition.

This is what I was thinking.

I can test the different methods and check for conflicts.
Starting with ideal for less N900 wear and adjust until happy.
Time will tell.

Are there any recommendations for Swappolube settings with swap on uSD or will it depend on the card?

sixwheeledbeast 2012-07-10 22:35

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Well my 64GB card arrived and so far so good.
No issues with lag and the system feels snapier at the moment.

I made two swaps of 800mb (1p2 and 1p3) and the rest FAT32 (1p1).

To start swap on MMC I created a file in event.d

etc/event.d/relocateswap
Code:

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

It seems (from testing) if the memory card is not accessable the script can not run and swap goes on (0p3) as per rcS-late.

Also I have added three QBW to view current swaps and swap between swap spaces.

Check Swaps
Code:

cat /proc/swaps | awk '/dev/ {print $1}'
The other two buttons are swap 1p2 on, swap 1p3 off and vice versa.
I am hoping when I have time to turn this into one script that can be run from cron or QBW etc.

Ideally something like:

if swap = 1p2 then swap on 1p3, swap off 1p2
if swap =1p3 then swap on 1p2, swap off 1p3
if swap = 0p3 then swap on 1p2, swap off 0p3
with some way of knowing if it's failed or not possible.

I would just use ereswap but that would defeat the object of lowering flash wear by only swapping one way.

Raimu 2012-07-10 22:46

Re: [DISCUSS] SDCard Swap Partition Methods..
 
Hee, that's a nice looping swap. Not just wear, this also should shorten the swapoff/on refresh slowness a fair bit since this ring moves the swap one way.

Estel 2012-07-11 01:29

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

Originally Posted by sixwheeledbeast (Post 1235661)
I would just use ereswap but that would defeat the object of lowering flash wear by only swapping one way.

Why so? In ereswap config, uou can define both main and "backup" swap as partitions on microSD ,(mmcblk1p2 and mmcblk1p3 in this case) which leaves internal swap out of use (it can even not exist) making it fully compatible with your use case :)

/Estel

sixwheeledbeast 2012-07-11 16:56

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

Originally Posted by Raimu (Post 1235669)
Not just wear, this also should shorten the swapoff/on refresh slowness a fair bit since this ring moves the swap one way.

Exactly :D

Quote:

Originally Posted by Estel (Post 1235733)
Why so? In ereswap config, you can define both main and "backup" swap as partitions on microSD ,(mmcblk1p2 and mmcblk1p3 in this case) which leaves internal swap out of use (it can even not exist) making it fully compatible with your use case :)

Compatible yes, but not exactly my plan.

My idea of having two swaps on microSD is so they can be used equally.
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.

The benefit's are quicker swap refresh and reduced, equal cell usage.

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 06:13.

vBulletin® Version 3.8.8