View Single Post
Posts: 32 | Thanked: 24 times | Joined on Sep 2010
#92
Sorry your right the -q does nothing (warnings scrolled past top of screen on N900, was doing things remotely till now).

What does work is if you use the switch for msdos mode, -d, it returns a similar list except that now now the linux swap is listed as Id=82, so we can use this instead.

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

script

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

end script
That works cleanly for me with no warning messages, though I have only ran it in a test script where I echo "$swapmicro" and it returns:
/dev/mmcblk1p2

I have also changed the awk part, so that instead of looking for the specific swap partition /mmcblk1p2/, it looks for the more general swap on /mmcblk1/.
I think this is what Whitewolf was suggesting in case people have their cards partitioned differently.
I think thats it now - ready to go?

EDIT: I have tested this now by adding to /etc/event.d/ and it works as expected. On reboot with no card present no swap changes are made. With swap on SD present it enables swap with the faster memory having a higher priority.

If you are going to do this I'd suggest putting it in file on its own - or if you are adding this to an existing tuning script, put it at the end as it will exit when no external swap is detected.
(Many thanks GameboyRMH and Whitewolf, this noob has learned a lot working on this with you)

Last edited by elipsoid; 2010-10-21 at 04:22. Reason: Have tested it now
 

The Following 3 Users Say Thank You to elipsoid For This Useful Post: