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 19: Line 19:
With maximum swappiness the kernel just discards the memory pages of some applications because it is already in swap space and cut a time. I believe it is a reason why Nokia set 100 by default for swappiness.
With maximum swappiness the kernel just discards the memory pages of some applications because it is already in swap space and cut a time. I believe it is a reason why Nokia set 100 by default for swappiness.
-
(EDIT by eero):
+
==Configure microSD card for swapping==
-
 
+
-
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==
+
-
 
+
-
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 81: Line 48:
There is an additional warning and that is that while the device is running and swap is turned on on microSD partition, you shouldn't take the card out. It would be the same as taking out a RAM stick while running.
There is an additional warning and that is that while the device is running and swap is turned on on microSD partition, you shouldn't take the card out. It would be the same as taking out a RAM stick while running.
-
 
-
==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>.
 
-
 
-
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>
 
-
# temporarily deactivate the eMMC swap: <code>swapoff /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:
 
-
 
-
<pre>
 
-
/home/user # cat /proc/swaps
 
-
Filename Type Size Used Priority
 
-
/dev/mmcblk0p3                          partition 786424 65464 0
 
-
/dev/mmcblk1p2                          partition 393272 97908 0
 
-
</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.
 
-
 
-
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.
 
[[Category:Power users]]
[[Category:Power users]]
[[Category:N900]]
[[Category:N900]]

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)