Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 02-15-2016, 11:26 AM   #1
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Using swap on a KT

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.

Last edited by knc1; 02-15-2016 at 11:31 AM.
knc1 is offline   Reply With Quote
Old 02-15-2016, 12:11 PM   #2
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
What about /mnt/base-us ?
eschwartz is offline   Reply With Quote
Advert
Old 02-15-2016, 12:25 PM   #3
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by eschwartz View Post
What about /mnt/base-us ?
I tried that - it seems that the fuse driver gets confused in some way (I ended up with two file type signatures on mmcblk0p4).

The '7th gen' devices are running a series 3.0.x kernel, not the 2.6.x kernel of earlier devices. So changes in internal behavior can be expected.

I can always try again - perhaps I did something wrong when testing.
And, I did not test on the KT (kern-2.6.x), only the PW-3 (kern-3.0.x).

Last edited by knc1; 02-15-2016 at 12:29 PM.
knc1 is offline   Reply With Quote
Old 02-15-2016, 12:31 PM   #4
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Alternatively, here's a good excuse to play with the partition tables.
eschwartz is offline   Reply With Quote
Old 02-15-2016, 01:18 PM   #5
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by eschwartz View Post
Alternatively, here's a good excuse to play with the partition tables.
PW-3 (Kernel 3.0.35) - USB mass storage not exported:
Code:
[root@kindle root]# cat /proc/self/mountinfo
13 1 179:1 / / ro,noatime,nodiratime - ext3 /dev/root ro,barrier=0,data=writeback
11 13 0:3 / /proc rw,nosuid,nodev,noexec,relatime - proc none rw
12 13 0:11 / /sys rw,nosuid,nodev,noexec,relatime - sysfs none rw
14 13 0:12 / /dev rw,relatime - tmpfs tmpfs rw,mode=755
15 14 0:13 / /dev/shm rw,relatime - tmpfs tmpfs rw
16 14 0:9 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620
17 13 0:14 / /var rw,relatime - tmpfs tmpfs rw,size=32768k
18 13 7:2 / /usr/share/X11/xkb ro,noatime,nodiratime - cramfs /dev/loop/2 ro
19 13 7:3 / /usr/java/lib/fonts ro,noatime,nodiratime - cramfs /dev/loop/3 ro
20 13 7:4 / /etc/kdb.src ro,noatime,nodiratime - cramfs /dev/loop/4 ro
21 13 7:5 / /usr/lib/locale ro,noatime,nodiratime - cramfs /dev/loop/5 ro
22 13 7:6 / /usr/share/keyboard ro,noatime,nodiratime - cramfs /dev/loop/6 ro
23 17 179:3 / /var/local rw,relatime - ext3 /dev/mmcblk0p3 rw,errors=continue,barrier=0,data=writeback
25 13 0:15 / /mnt/us rw,nosuid,nodev,noatime - fuse.fsp fsp rw,user_id=0,group_id=0,allow_other
24 13 7:0 / /mnt/base-us rw,noexec,noatime,nodiratime - vfat /dev/loop/0 rw,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro

[root@kindle root]# losetup /dev/loop/1
losetup: /dev/loop/1: No such device or address
PW-3 (Kernel 3.0.35) - USB mass storage auto exported:
Code:
[root@kindle root]# cat /proc/self/mountinfo
13 1 179:1 / / ro,noatime,nodiratime - ext3 /dev/root ro,barrier=0,data=writeback
11 13 0:3 / /proc rw,nosuid,nodev,noexec,relatime - proc none rw
12 13 0:11 / /sys rw,nosuid,nodev,noexec,relatime - sysfs none rw
14 13 0:12 / /dev rw,relatime - tmpfs tmpfs rw,mode=755
15 14 0:13 / /dev/shm rw,relatime - tmpfs tmpfs rw
16 14 0:9 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620
17 13 0:14 / /var rw,relatime - tmpfs tmpfs rw,size=32768k
18 13 7:2 / /usr/share/X11/xkb ro,noatime,nodiratime - cramfs /dev/loop/2 ro
19 13 7:3 / /usr/java/lib/fonts ro,noatime,nodiratime - cramfs /dev/loop/3 ro
20 13 7:4 / /etc/kdb.src ro,noatime,nodiratime - cramfs /dev/loop/4 ro
21 13 7:5 / /usr/lib/locale ro,noatime,nodiratime - cramfs /dev/loop/5 ro
22 13 7:6 / /usr/share/keyboard ro,noatime,nodiratime - cramfs /dev/loop/6 ro
23 17 179:3 / /var/local rw,relatime - ext3 /dev/mmcblk0p3 rw,errors=continue,barrier=0,data=writeback
25 13 0:15 / /mnt/us rw,nosuid,nodev,noatime - fuse.fsp fsp rw,user_id=0,group_id=0,allow_other

[root@kindle root]# losetup /dev/loop/0
/dev/loop/0: 8192 /dev/mmcblk0p4

[root@kindle root]# losetup /dev/loop/1
losetup: /dev/loop/1: No such device or address

[root@kindle root]# ls -la /mnt/us
drwxrwxrwx    2 root     root          1024 Apr 15  2015 .
drwxrwxr-x    8 root     root          1024 Apr 15  2015 ..
Note that although /mnt/us remains "mounted" it's contents are not visible.
Note also that /mnt/base-us (which gets un-mounted) is still in-use by the device-to-device translation in the VFS layers.
I am fairly sure that kernel 2.6.x did not support device-to-device translation.

@NiLJe: note -
Code:
[root@kindle root]# r=$(cat /proc/self/mountinfo | grep '/dev/root') ; set $(echo $r) ; echo $3
179:1
179:1 == 'main'
179:2 == 'diags'
At least until Lab126 changes the partition order on the eMMC.
knc1 is offline   Reply With Quote
Advert
Old 02-16-2016, 12:54 AM   #6
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Actually, I was pondering the idea of repartitioning the userstore, making a swap partition that isn't exported over USB.
eschwartz is offline   Reply With Quote
Old 02-16-2016, 12:56 AM   #7
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
Quote:
Originally Posted by eschwartz View Post
Actually, I was pondering the idea of repartitioning the userstore, making a swap partition that isn't exported over USB.
It has been done and report on in this forum.
Been a long time ago, I don't have a clue when or who.
knc1 is offline   Reply With Quote
Old 02-16-2016, 01:13 AM   #8
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
I also remember it was done, but I was hoping someone else would remember where! And how.
eschwartz is offline   Reply With Quote
Old 02-16-2016, 02:09 AM   #9
knc1
Going Viral
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
I can give the parts of the chore I know of -

The eMMC at its base address has a DOS HD format disk label (mbr area not used).

During boot, the address, size and alignment of partitions 1, 2, and 3 are checked.
Note: Partition 1 **DOES NOT** start immediately following the partition table, there is a 16Mbyte gap (at least on the 4Gbyte machines, haven't checked the 2Gbyte machines yet).

The address and alignment of partition 4 is checked, the size is set to match the remainder of the eMMC.

At the start address of partition 4 is another DOS, HD format disk label.
(yes, each partition can have its own partition table, but you will have a hell of a time finding it in the MS documents (it is, or was, in there).

??? I don't recall what things are tested about the sub-partition. ???

Only the first partition table entry is used. (you want to add a partition 2).

The partition table (1), partition 4 is mounted with an 8192 byte offset, placing the mbr area and (sub-) partition table (2) **OUTSIDE** of the fuse layer.
THAT is the reason for the initial /dev/loop/0 layer - losetup can start at an offset.

Although FAT-32 can be re-sized, I don't know if the fuse layer would follow the change in size. (You have to shrink the first (and only) partition to have room for the second.)

If trying this myself, I would first (try) to free all use of t1p4:t2p1 (how you like that abbreviation?) that is 'covered' by the fuse layer.

I am guessing from this point on -
Remove the kernel gadget module -
Shut down the fuse layer -
un-mount /mnt/us and /dev/loop/0 (or /dev/loop0 depending on kernel version) -
un-mount /mnt/base-us if it is still there (???) -
re-size the FAT-32 first partition of the second level partition table -
re-size the first partition of the second level partition table -
The above two re-size operations are so the system doesn't decide some of the system required contents of USB mass storage are missing and re-build everything you just did.
create a second partition in the second level partition table -
re-mount everything you un-mounted -
start everything you had to stop -
re-load the kernel modules you had to un-load -
Hope the fuse layer stays within the new confines of the smaller first partition -
Make use of the new second partition as desired.

The exact details of that procedure is left as a student exercise.

Next Morning Edit:
A whole lot of that would be simplified by doing the work from 'diags' -

Last edited by knc1; 02-16-2016 at 09:30 AM.
knc1 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to swap K3 buttons? Stingo Amazon Kindle 3 09-18-2011 08:09 PM
Swap howdies? durkinrobinson Introduce Yourself 12 09-06-2010 10:14 PM
Screen Swap Hrant Amazon Kindle 7 08-31-2010 08:42 AM
DR800 swap out 3G nprnncbl iRex 3 06-07-2010 04:45 PM
iLiad SWAP on iLiad tirsales iRex Developer's Corner 16 09-01-2008 04:20 PM


All times are GMT -4. The time now is 08:28 PM.


MobileRead.com is a privately owned, operated and funded community.