Quantcast
Channel: MobileRead Forums - Kindle Developer's Corner
Viewing all articles
Browse latest Browse all 4475

Hardware Using swap on a KT

$
0
0
On a KT (B00F - fw-5.3.7.3), 256Mbyte 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          31729    13083    17008  43% /var/local

The Busybox/Ash command line can do simple math, find number of erase blocks:
Code:

[root@kindle local]# echo $((1024*1024*8/4096))
2048

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=2048
2048+0 records in
2048+0 records out
8388608 bytes (8.0MB) copied, 0.186354 seconds, 42.9MB/s

The swap file requires a special format:
Code:

[root@kindle local]# mkswap ./swap
Setting up swapspace version 1, size = 8384 kB
no label, UUID=7b04d237-2476-4b2c-8b7b-0a5b58bf3006

The above completes the (one-time) setup of a K5 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:        255660    248608      7052          0      30308      85580
-/+ buffers/cache:    132720    122940
Swap:        7852          0      7852

Now open Kindle User's Guide
Code:

[root@kindle local]# free
            total      used      free    shared    buffers    cached
Mem:        255660    247056      8604          0      22084      80048
-/+ buffers/cache:    144924    110736
Swap:        7852      2068      5784

Browse the user's guide, with and without per-page refresh enabled.
Then close Kindle User's Guide
Code:

[root@kindle local]# swapon -s
Filename            Type    Size    Used    Priority
/var/local/swap    file    7852    2056    -1

[root@kindle local]# df .
Filesystem          1K-blocks      Used Available Use% Mounted on
/dev/mmcblk0p3          31729    21306      8785  71% /var/local

For users with a lot of books, perhaps using only 4Mbyte (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.

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. ;)

Note 3:
The KT is the earliest Kindle with a large enough /var/local partition to make the above practical.

Viewing all articles
Browse latest Browse all 4475

Trending Articles