On a PW-3 (G0
90 G1 - fw-5.6.1.1), 512Mbyte Ram, 4Gbyte eMMC ::
Using the system feature that /var/local is always mounted; either in 'main' or 'diags'.
Setup to use 1/4 of /var/local for a system swap file.
Over ssh (or telnet or serial port or from kTerm) -
Code:
[root@kindle root]# cd /var/local
[root@kindle local]# df .
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mmcblk0p3 63461 16692 43493 28% /var/local
Note that the PW-3 has a /var/local partition twice the size of what it was on the KT.
The Busybox/Ash command line can do simple math, find number of erase blocks:
Code:
[root@kindle local]# echo $((1024*1024*16/4096))
4096
Linux swap files **must** be initialized to zeros (no sparse files allowed):
Code:
[root@kindle local]# dd if=/dev/zero of=swap bs=4096 count=4096
4096+0 records in
4096+0 records out
16777216 bytes (16.0MB) copied, 0.627486 seconds, 25.5MB/s
Interesting, the 'bulk write' on the PW-3 eMMC is 1/2 the rate as on the KT eMMC. ( ? )
The swap file requires a special format:
Code:
[root@kindle local]# mkswap ./swap
Setting up swapspace version 1, size = 16773 kB
no label, UUID=abd86682-51a1-42f6-aede-228fea736287
The above completes the (one-time) setup of a PW-3 swapfile.
Its use by the system is controlled by the swapon and swapoff commands.
Code:
[root@kindle local]# swapon ./swap
[root@kindle local]# free
total used free shared buffers cached
Mem: 515344 503292 12052 0 291540 54556
-/+ buffers/cache: 157196 358148
Swap: 16016 0 16016
Now open Kindle Paperwhite User's Guide
Code:
[root@kindle local]# free
total used free shared buffers cached
Mem: 515344 500168 15176 0 275520 60604
-/+ buffers/cache: 164044 351300
Swap: 16016 2412 13604
Browse the user's guide.
Then close Kindle Paperwhite User's Guide
Code:
[root@kindle local]# swapon -s
Filename Type Size Used Priority
/var/local/swap file 16016 1556 -1
[root@kindle local]# df .
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mmcblk0p3 63461 33148 27037 55% /var/local
For users with a lot of books, perhaps using only 8Mbyte (half the above size) for the swap file would be a better choice.
Even using only 2Mbyte of file space for the swap file reduces the kernel's page management workload.
To the end-user, the appearent change is a more responsive Kindle.
Since the above steps do not make an addition to /etc/fstab, the use of the swap file will 'go away' with the next re-boot.
That is: the 'swapon /var/local/swap' command needs to re-issued after each reboot (the normal system shutdown will take care of the 'swapoff' process).
When (IF) I get the spare time, I'll create a KUAL extension button (set) to let the non-technical user deal with all of the above.
Note 1:
If your 'main' system chokes by running out of space on /var/local -
just re-boot into 'diags' and remove the /var/local/swap file.
An easy way to do that, is to have RP (Rescue Pack) installed.
The RP re-enables the recognition of the flag file: ENABLE_DIAGS, previously last seen on the KT.
Note 2:
Other directions you find may say to put the swap file in user storage.
Not a good idea, because the Kernel can't access user storage when it is exported as mass storage over USB.
And the Kernel really, really does not like to have the backing store of its swap file suddenly disappear.