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 11-06-2012, 09:08 AM   #46
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Quote:
Originally Posted by knc1 View Post
fdisk -l
(that's: ell)
true. but you don't the amusing warning
twobob is offline   Reply With Quote
Old 05-02-2016, 03:32 PM   #47
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by eureka View Post
p4 has an [embedded] partition table on it's own. You can edit this table, shrink userstore parition (it's a single partition embedded in p4) from the end, then add a new primary partition into freed space of p4. ...
That is TOTALLY normal. In fact, a standard MBR partition table can only have FOUR primary partitions. Any additional partitions must be in an extended partition (which has its own partition table). This is exactly what you are seeing -- p4 is an extended partition. This is normal on anything with an MBR partition table (which works on pretty much any computer or embedded device, as opposed to GPT partitions which are typically restricted to large powerful devices).
geekmaster is offline   Reply With Quote
Advert
Old 05-05-2016, 08:11 PM   #48
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
As I mentioned above, adding a fifth primary partition to an MBR partition table is a bad idea. Leaving it as unused space and then using it anyway is an ugly hack. The right way is to shorten the first logical partition in the extend partition table in mmpblk0p4. I will list the master and extended partition tables here (this is on a K5):
Code:
[root@kindle us]# sfdisk -l /dev/mmcblk0

Disk /dev/mmcblk0: 120832 cylinders, 4 heads, 16 sectors/track
Units = cylinders of 32768 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/mmcblk0p1   *   1024   12223   11200     358400   83  Linux
/dev/mmcblk0p2      12224   14271    2048      65536   83  Linux
/dev/mmcblk0p3      14272   15295    1024      32768   83  Linux
/dev/mmcblk0p4      15296  120831  105536    3377152    b  W95 FAT32
[root@kindle us]# sfdisk -l /dev/mmcblk0p4 --force

Disk /dev/mmcblk0p4: 105536 cylinders, 4 heads, 16 sectors/track
Units = cylinders of 32768 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/mmcblk0p4p1          0+ 105535  105536-   3377144    b  W95 FAT32
/dev/mmcblk0p4p2          0       -       0          0    0  Empty
/dev/mmcblk0p4p3          0       -       0          0    0  Empty
/dev/mmcblk0p4p4          0       -       0          0    0  Empty
[root@kindle us]#
Note that I had to force sfdisk to list the extended partition, to stop it from complaining.

As shown above, the extended partition table (inside mmcblk0p4) has three empty extended partitions available. Placing multiple partitions inside mmcblk0p4 *should* allow them to be exported to some host operating systems (though windows tends to only show the first partition on USB flash devices).

And just to prove that mmcblk0p4 is special (includes its own partition table), here is an example of trying to list the partitions in mmcblk0p3:
Code:
[root@kindle us]# sfdisk -l /dev/mmcblk0p3 --force

Disk /dev/mmcblk0p3: 1024 cylinders, 4 heads, 16 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
 /dev/mmcblk0p3: unrecognized partition table type
No partitions found
[root@kindle us]#
EDIT:And in fact, this is why the userstore partition is loop mounted with an offset, to skip over the MBR partition table and mount the internal extended partition (simulating mounting a virtual mmcblk0p4p1 which is not provided as its own device in /dev). You need to extract offsets from the extended partition table and loop mount the contents with that offset.

Last edited by geekmaster; 05-05-2016 at 09:17 PM.
geekmaster is offline   Reply With Quote
Old 05-05-2016, 09:12 PM   #49
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
And the "userstore" script contains this code snippet (with env vars resolved):
PHP Code:
    # try to read back the existing partition size
    
PART_SIZE=`sfdisk --force -l /dev/mmcblk0p4 | awk '$1 ~ '/p1/\ '{ print $5 }'`

    if [ -
"${PART_SIZE}]; then
        _CREATE
=1
    fi

    
if [ ${_CREATE} -ne 0 ]; then
        
# clear the first cylinder
        
dd if=/dev/zero of=${MNTUS_DEVbs=${_CYLSIZEcount=1

        
# create the volume partition
        
sfdisk ---force -uS ${MNTUS_DEV} <<EOI
${PART_START},,b
EOI

        
# read back the created partition size
        
PART_SIZE=`sfdisk --force -l ${MNTUS_DEV} | awk '$1 ~ '/${_BASE_MNTUS_DEV}p1/\ '{ print $5 }'
Notice that this script (used to blast and rebuild the /mnt/us userstore) lists the partition structure INSIDE /dev/mmcblk0p4, and then extracts size information from "p1" (i.e. mmcblk0p4p1), where the actual loop-mountable partition resides.

It might be a little more obvious what is going on here if they had created device nodes for the extended partitions, instead of loop mounting with offsets (though it helps that the offsets and sizes are calculated using partition information returned by sfdisk). It should be "relatively" easy to shrink mmcblk0p4p1 and add mmcblk0p4p2. And with a little luck, USB-exporting mmcblk0p4 would also automagically export its internal extended partitions (even though windows may choose to ignore all but the first). A sane OS like linux should see all the partitions defined in the extended partition table shared over USB.

EDIT: I have been reading lots of kindle system (and installer update) scripts, trying to eduficate myself on this subject. This topic seemed appropriate to post these little notes to myself (and anybody else who may benefit from them).

Last edited by geekmaster; 05-05-2016 at 09:29 PM.
geekmaster is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PRS-T1 Questions about repartitioning simongee Sony Reader Dev Corner 47 11-06-2012 05:07 AM
Kindle Touch: Bricked and readonly filesystem pmugabi Kindle Developer's Corner 6 09-17-2012 01:50 AM
PRS-T1 Completed guide for repartitioning. homeos Sony Reader Dev Corner 20 04-05-2012 11:54 AM
PB360 Filesystem error ArchCarrier PocketBook 4 06-06-2010 08:46 AM
Stock kindle 2 filesystem (2.0.3 or newer preferred) eousphoros Kindle Developer's Corner 10 02-17-2010 08:40 PM


All times are GMT -4. The time now is 11:13 AM.


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