View Single Post
Old 10-31-2012, 03:38 PM   #14
eureka
but forgot what it's like
eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.eureka ought to be getting tired of karma fortunes by now.
 
Posts: 741
Karma: 2345678
Join Date: Dec 2011
Location: north (by northwest)
Device: Kindle Touch
I've tried to reparition /dev/mmcblk0p4 (on Kindle Touch 5.1.2). So, here is how-to.
  • Make BACKUP of your Kindle userstore parition (i.e. /mnt/us). It will be destroyed!
  • stop framework. It's not strictly required, but framework is the most obvious consumer of userstore parition content, so let's disable it just in paranoia considerations:
    Code:
    [root@kindle root]# stop framework
  • unmount userstore parition. Also check if /mnt/us and/or /mnt/base-us were/are mounted:
    Code:
    [root@kindle root]# mount | grep -c us
    2
    Code:
    [root@kindle root]# /etc/upstart/userstore stop
    Code:
    [root@kindle root]# mount | grep -c us
    0
  • make copy of userstore script:
    Code:
    [root@kindle root]# cp /etc/upstart/userstore /var/tmp/root/userstore
  • change copy of userstore script (UPD: read this beforehand). The changed script will create two partitions at /dev/mmcbk0p4: first is the default Kindle userstore partition (already formatted), second is unformatted free space. Size of first parition could be changed in line with definition of PART_SIZE variable. In this diff, it's set to 1GB (1024 * 1024 * 1024 is 1GB in bytes and 512 is sector size):
    PHP Code:
    --- /etc/upstart/userstore
    +++ /var/tmp/root/userstore
    @@ -29,+29,@@
      
    PART_START=${_TRACKSIZE}
     
      
    # try to read back the existing partition size
    PART_SIZE=`sfdisk --force -l ${MNTUS_DEV} | awk '$1 ~ '/${_BASE_MNTUS_DEV}p1/\ '{ print $5 }'`
    PART_SIZE=`expr 1024 \* 1024 \* 1024 \/ 512`
    NEXT_PART_START=`expr ${PART_START} \+ ${PART_SIZE}`
     
      if [ -
    "${PART_SIZE}]; then
        _CREATE
    =1
    @@ -41,+42,@@
     
        
    # create the volume partition
        
    sfdisk ---force -uS ${MNTUS_DEV} <<EOI
    -${PART_START},,b
    +${PART_START},${PART_SIZE},b
    +${NEXT_PART_START}
     
    EOI
     
        
    # read back the created partition size
    @@ -237,+239,@@
     
    # returned status is that of the called routine
     
     
    case "$1" in
    -  startstart_us ;;
    -  
    stopstop_us ;;
    -  
    initinit_us ;;
    -  *) echo 
    "usage: $0 [start|stop|init]" ; exit ;;
    +  
    repartitioninit_us "create";;
    +  *) echo 
    "usage: $0 repartition" ; exit ;;
     
    esac 
  • did you backup your userstore parition? If not, backup it right now!
  • execute changed userstore script (output is skipped):
    Code:
    [root@kindle root]# sh /var/tmp/root/userstore repartition
  • mount new Kindle userstore parition:
    Code:
    [root@kindle root]# /etc/upstart/userstore start
  • check for changes:
    Code:
    [root@kindle root]# df -h
    Filesystem                Size      Used Available Use% Mounted on
    /dev/root               340.2M    232.9M     90.3M  72% /
    tmpfs                   124.8M     72.0K    124.8M   0% /dev
    tmpfs                   124.8M         0    124.8M   0% /dev/shm
    tmpfs                    32.0M    340.0K     31.7M   1% /var
    /dev/mmcblk0p3           31.0M     16.2M     13.1M  55% /var/local
    /dev/loop/0            1018.0M    552.0K   1017.5M   0% /mnt/base-us
    fsp                    1018.0M    552.0K   1017.5M   0% /mnt/us
    Code:
    [root@kindle root]# sfdisk --force -l /dev/mmcblk0p4
    
    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+  32768-  32768    1048576    b  W95 FAT32
    /dev/mmcblk0p4p2      32768+ 105535   72768-   2328568   83  Linux
    /dev/mmcblk0p4p3          0       -       0          0    0  Empty
    /dev/mmcblk0p4p4          0       -       0          0    0  Empty
  • start framework:
    Code:
    [root@kindle root]# start framework
New userstore parition survives reboot and works as expected when Kindle connected to computer.

Your new partition (i.e. new free space) could be destroyed by system userstore script in some rare cases:
  • if size of /dev/mmcbk0p4p1 will be 0 (as reported by sfdisk --force -l /dev/mmcblk0p4),
  • if /usr/sbin/mntus mount will return failure (not zero exit code).
This possibility of destroying could be avoided with slight changes in /etc/upstart/userstore, but I think these cases are really rare, so they doesn't matter.

So, now you have free space. It should be formatted and mounted as loopback device. (Maybe I'll describe further setup a bit later, if nobody will do it before me...)

Last edited by eureka; 11-05-2012 at 09:03 AM. Reason: add link to alternative userstore script diff
eureka is offline   Reply With Quote