Active Topics

 


Reply
Thread Tools
Posts: 32 | Thanked: 24 times | Joined on Sep 2010
#81
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?
 

The Following User Says Thank You to elipsoid For This Useful Post:
Posts: 561 | Thanked: 75 times | Joined on Jan 2010 @ Spain
#82
Cat /proc/swaps
/dev/mmcblk0p3 Priorit=-1
/dev/mmcblk1p3 Priorit=-2
 
Posts: 561 | Thanked: 75 times | Joined on Jan 2010 @ Spain
#83
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?
 
Posts: 692 | Thanked: 264 times | Joined on Dec 2009
#84
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
__________________
"Impossible is not in the Maemo vocabulary" - Caballero

Last edited by GameboyRMH; 2010-10-20 at 19:38. Reason: Improvements to script from WhiteWolf
 
Posts: 561 | Thanked: 75 times | Joined on Jan 2010 @ Spain
#85
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

Last edited by WhiteWolf; 2010-10-20 at 16:06.
 

The Following User Says Thank You to WhiteWolf For This Useful Post:
Posts: 692 | Thanked: 264 times | Joined on Dec 2009
#86
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)
__________________
"Impossible is not in the Maemo vocabulary" - Caballero
 
Posts: 561 | Thanked: 75 times | Joined on Jan 2010 @ Spain
#87
I look forward to this script! Good idea.

.. If I can help, I will love it.
 
Posts: 32 | Thanked: 24 times | Joined on Sep 2010
#88
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.
 
Posts: 561 | Thanked: 75 times | Joined on Jan 2010 @ Spain
#89
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.
 
Posts: 124 | Thanked: 105 times | Joined on Jul 2010
#90
 
Reply


 
Forum Jump


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