Editing Swap on microSD

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 23: Line 23:
The situation will also change after a while because swap becomes fragmented (parts of processes' memory are spread all over swap in little pieces).  I.e. testing the speed only for few hours after boot isn't enough, new setting needs to be tested for several days.
The situation will also change after a while because swap becomes fragmented (parts of processes' memory are spread all over swap in little pieces).  I.e. testing the speed only for few hours after boot isn't enough, new setting needs to be tested for several days.
-
==Swap Fragmentation==
+
==Configure microSD card for swapping==
-
 
+
-
Swap fragmentation starts to occur, when total number of megabytes written during swap's life time exceed it's maximum size. Until that, swap is written in purely sequential manner (blocks that are no longer needed, are marked as free, but never used) - however, after reaching end of swap space, previously used (freed) blocks are rewritten, using new content. This means no longer writing sequentially, causing massive slowdowns, to already slow (compared to RAM) swap. A workaround to this is to disable and enable swap again - linuxswap filesystem content doesn't live through restarts, and once re-enabled, is written sequentially again.
+
-
 
+
-
Swapping, Disabling and Re-enabling swap spaces can take upto a few minutes.
+
-
 
+
-
Information about your current swap spaces can be found by entering
+
-
cat /proc/swaps
+
-
in a [[Terminal]]
+
-
 
+
-
===Solutions to Fragmentation===
+
-
 
+
-
====Script====
+
-
 
+
-
Moved to [[Talk:Swap_on_microSD]]
+
-
Options currently in discussion.
+
-
 
+
-
====Flopswap====
+
-
A GUI application [[Flopswap]] is available.
+
-
This application doesn't depend on any packages and can check used blocks and refresh swap.
+
-
 
+
-
More information is available on the [[Flopswap]] wiki
+
-
 
+
-
====Ereswap====
+
-
An application [[Ereswap]] is available.
+
-
This application as well as checking for defragmention and refreshing swap, also edits /etc/event.d/rcS-late.
+
-
This edit makes sure your primary swap partition on the Micro SD is available during booting.
+
-
More information is available on the [[Ereswap]] wiki
+
-
 
+
-
==Manually configure microSD card for swapping on the device==
+
The microSD card must be split into at least 2 partitions. The first one should be FAT32 (vfat) formatted and the second one must be formatted for linux swap (type 82) and about 384 MB in size. You can change the size of it, but this value should be suitable for most people.
The microSD card must be split into at least 2 partitions. The first one should be FAT32 (vfat) formatted and the second one must be formatted for linux swap (type 82) and about 384 MB in size. You can change the size of it, but this value should be suitable for most people.
Line 84: Line 55:
==Swap priorities==
==Swap priorities==
-
In order to utilize both swap partitions to balance the I/O load (striping), they should have the same priority. The <code>/bin/swapon</code> command shipped with Maemo is the busybox version that does not support <code>-p</code> option. If you don't have Easy Debian environment installed, download the stock Debian mount package for the armel architecture and extract (<code>-x</code>) the swapon binary from it, and copy it somewhere e.g. <code>/sbin/swapon.debian</code>.
+
In order to utilize both swap partitions to balance
 +
the I/O load (striping), they should have the same priority. The <code>/bin/swapon</code> command shipped with Maemo is the busybox version that does not support <code>-p</code> option. If you don't have Easy Debian environment installed, download the stock Debian mount package for the armel architecture and extract (<code>-x</code>) the swapon binary from it, and copy it somewhere e.g. <code>/sbin/swapon.debian</code>.
It seems that it's not possible to use <code>-p -1</code> to match the priority of the default eMMC swap partition. I use the following trick:
It seems that it's not possible to use <code>-p -1</code> to match the priority of the default eMMC swap partition. I use the following trick:
-
# activate the microSD swap: <code>swapon.debian -p 0 /dev/mmcblk1p2</code>
+
* activate the microSD swap: <code>swapon.debian -p 0 /dev/mmcblk1p2</code>
-
# temporarily deactivate the eMMC swap: <code>swapoff /dev/mmcblk0p3</code>
+
* temporarily deactivete the eMMC swap: <code>swapooff /dev/mmcblk0p3</code>
-
# activate it again with matching priority: <code>swapon.debian -p 0 /dev/mmcblk0p3</code>
+
* activate it again with matching priority: <code>swapon.debian -p 0 /dev/mmcblk0p3</code>
After that your swaps should look like this:
After that your swaps should look like this:
Line 101: Line 73:
</pre>
</pre>
-
Depending on the performance of your microSD card, your N900 might now feel much faster when swapping takes place, about the same, or even slower - YMMV. My N900 definitely seems to have less those total I/O trashing episodes lasting 5-10 minutes, where you might think your N900 just died, after doing heavy I/O (e.g. download a 100 MB podcast with gPodder) after activating this dual-swap scheme.  
+
Depending on the performance of your microSD card, your N900 might now feel much faster when swapping takes place, about the same, or even slower - YMMV. My N900 definedly seems to have less those total I/O trashing episodes lasting 5-10 minutes, where you might think your N900 just died, after doing heavy I/O (e.g. download a 100 MB podcast with gPodder) after activating this dual-swap scheme.  
Note: In my testing my N900 crashed when I tried to fill the VFAT data partition on the microSD with something like <code>dd</code> from <code>/dev/null</code> to a file. It's propably best to dedicate the whole microSD card for swap, if possible.
Note: In my testing my N900 crashed when I tried to fill the VFAT data partition on the microSD with something like <code>dd</code> from <code>/dev/null</code> to a file. It's propably best to dedicate the whole microSD card for swap, if possible.

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)