View Single Post
Old 11-01-2012, 10:23 AM   #26
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
Quote:
Originally Posted by NiLuJe View Post
Just a quick note to point out that (according to the PW's cramfs mount scripts), loop/1 is historically reserved for the SDCard (while loop/0 is the userstore). (And the PW uses a couple of loop devices for cramfs, too).
Indeed, on PW loops from 2 to 7 are already used. I've also found mentioning of /dev/loop/1 in some system scripts (/usr/sbin/wfm_mount, /usr/sbin/wfm_erase). So it's safer to create /dev/loop/8 and use it, as in this changed upstart script:
Spoiler:
Code:
start on started system and started syslog
stop on stopping filesystems

pre-start script
  source /etc/upstart/functions

  [ -e /dev/loop/8 ] || mknod /dev/loop/8 b 7 8
  losetup -o 1075838976 /dev/loop/8 /dev/mmcblk0p4
  mount -t ext3 /dev/loop/8 /mnt/newpart
  
  f_log I newpart mount "newpart is mounted"
end script

post-stop script
  source /etc/upstart/functions

  umount /mnt/newpart
  losetup -d /dev/loop/8
  [ -e /dev/loop/8 ] && rm /dev/loop/8
  
  f_log I newpart umount "newpart is unmounted"
end script


Quote:
Originally Posted by EternalCyclist View Post
Sorry, I misunderstood you. I also don't know how to mount it directly on Kindle.
But on the connected PC I could mount it directly with the mount command.
- On the other hand, why would someone want to mount the ext3 partition on the PC via usbdrive. I am prefering sshfs.

So: The offset could be written to the partition table. But it is practically no use. I agree.
OMG, I've just understood what you've already knew. This new parition will be seen by computer when KT will be connected by USB.

While it generally doesn't bring any harm, sometimes Linux system automounts all paritions on removable device (such as Kindle) and then this parition could be used by heedless user simultaneously from computer side and Kindle side. So there is some value in skipping of creating of new parition (i.e. skipping of making a new record in parition table) and then just using free space after shrinked userstore parition as-is.

Here is diff of userstore from Kindle Touch 5.1.2 with just shrinking of userstore parition:
Spoiler:
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`
 
     if [ -
"${PART_SIZE}]; then
         _CREATE
=1
@@ -41,+41,@@
 
         
# create the volume partition
         
sfdisk ---force -uS ${MNTUS_DEV} <<EOI
-${PART_START},,b
+${PART_START},${PART_SIZE},b
 EOI
 
         
# read back the created partition size
@@ -237,+237,@@
 
# 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 

And here is command for calculating absolute offset of new free space (in bytes, from start of eMMC device):
Code:
[root@kindle root]# expr 512 \* \( \
>   $(sfdisk -uS -l --force /dev/mmcblk0p4 | awk '/mmcblk0p4p1/ {print $3 + 1}') \
>   \+ $(cat /sys/class/block/mmcblk0p4/start) \
> \)
eureka is offline   Reply With Quote