maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   Using Micro SD Card as Virtual Ram on Nokia N900? (https://talk.maemo.org/showthread.php?t=42357)

elipsoid 2010-10-19 21:22

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Thanks Whitewolf that looks alot safer. What do you get for the swap priorities when you cat /proc/swaps ?

As I am personally going to stick to running a script manually after a reboot, and following Whitewolfs lead using sfdisk, I have added the lines below to my tuning script to ensure the uSD swap is available before making any changes.
Code:

testmicro="/dev/mmcblk1p2"
swapmicro=$(sfdisk -l /dev/mmcblk1 | grep /dev/mmcblk1p2 | awk '/mmcblk1p2/ {print $1}')
    if [ "$testmicro" == "$swapmicro" ]; then
      swapon /dev/mmcblk1p2
      swapoff /dev/mmcblk0p3
      swapon /dev/mmcblk0p3
    else
      echo "Cannot find swap parition on uSD card, swap still on internal memory"
    fi

You could of course run this at startup, and if the swap partition on the removable memory is not available, things will stay as standard. If the swap on the card is available then both partitions will be used, with the faster memory (assuming it is faster, I'm using a class6) being utilised primarily.

I have tested this by running with no SD card, and it works; if mmcblk1p2 is not present it will make no swap changes.

I'd like to be able to get this added to the wiki page, as the current instructions only sets up the faster swap as secondary- and it will never get used considering the huge default primary swap. As I've said I'm kinda new to all this so I wouldn't dream of doing so unless somebody with some experience had a look at the above code and gave me some feedback.

Does it look safe enough to add to the wiki?

WhiteWolf 2010-10-19 22:06

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Cat /proc/swaps
/dev/mmcblk0p3 Priorit=-1
/dev/mmcblk1p3 Priorit=-2

WhiteWolf 2010-10-19 22:14

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
I like but I see a limitation because you say what the swap.

I watch as it automatically adapt to the example that I put myself and not depend on the human well.

How to place her at the start to run?

GameboyRMH 2010-10-20 13:35

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Here's a startup script I made (goes in /etc/events.d/) based on elipsoid's script to check for the microSD swap file before changing the swap configuration. I broke some of the commands into two lines because depending on how you partitioned your MicroSD, you might get un-suppressable warning messages from sfdisk that would mess up the process.

Code:

start on started hildon-desktop
stop on starting shutdown
console none
service

script

drivelist=$(sfdisk -lnq /dev/mmcblk1)
swapmicro=$(echo "$drivelist" -n | grep swap | awk '/mmcblk1p2/ {print $1}')
if [ "$swapmicro" ]; then
    swapon $swapmicro
    swapoff /dev/mmcblk0p3
    swapon /dev/mmcblk0p3
fi

end script


WhiteWolf 2010-10-20 16:03

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
With the code as you wrote it I do not ever ride swap the SD.

I would remove the following line:
Code:

testmicro = "/ dev/mmcblk1p2"
Modify the line ...
Code:

swapmicro = $ (echo "$ drivelist"-n | grep / dev/mmcblk1p2 | awk '/ mmcblk1p2 / {print $ 1}')
For these other ...
Code:

drivelist = $ (sfdisk -ln /dev/mmcblk1 | grep swap)
swapmicro = $ (echo "$ drivelist"-n | awk ' /mmcblk1p/ {print $ 1}')

Show only that partition is a swap rate, regardless of the number of partition.

Then modify the following lines ...
Code:

if [ "$ testmicro" == "$ swapmicro" ]; then
    swapon / dev/mmcblk1p2
    swapoff / dev/mmcblk0p3
    swapon / dev/mmcblk0p3

For these, that would trigger the swap of the card as your indicastes:
Code:

if [ $ swapmicro ]; then
    swapon $ swapmicro
    swapoff /dev/mmcblk0p3
    swapon /dev/mmcblk0p3


GameboyRMH 2010-10-20 16:22

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
My script worked fine but I'm going to incorporate your improvements into my earlier post (with one little change to deal with sfdisk's warning messages)

WhiteWolf 2010-10-20 18:44

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
I look forward to this script! Good idea.

.. If I can help, I will love it.

elipsoid 2010-10-20 19:27

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
Good stuff guys, this is looking very polished and robust - certanly a smarter way of doing things and nice and compact.

Gameboy, the -q switch for sfdisk surpresses warning messages, I've just tried it and it works.

WhiteWolf 2010-10-20 19:33

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
I tested with the amendment proposed and returns nothing if there are error messages by sfdisk.

I confirm that the "-q" sfdisk output prevents error messages.

nman 2010-10-20 19:35

Re: Using Micro SD Card as Virtual Ram on Nokia N900?
 
On a related note...

http://www.brighthand.com/default.as...2+GB+microSDHC


All times are GMT. The time now is 19:37.

vBulletin® Version 3.8.8