View Single Post
Old 07-14-2018, 08:43 AM   #37
m4mmon
Enthusiast
m4mmon is my name, but call me Ishmael.m4mmon is my name, but call me Ishmael.m4mmon is my name, but call me Ishmael.m4mmon is my name, but call me Ishmael.m4mmon is my name, but call me Ishmael.m4mmon is my name, but call me Ishmael.m4mmon is my name, but call me Ishmael.m4mmon is my name, but call me Ishmael.m4mmon is my name, but call me Ishmael.m4mmon is my name, but call me Ishmael.m4mmon is my name, but call me Ishmael.
 
Posts: 49
Karma: 107174
Join Date: Mar 2012
Device: PB631, PB741, PB840
I will try to answer all your questions.

0/ Yes I "dd"-ed the original SD card and "dd"-ed the image on the new one.

1/ Yes.

(check full res here: https://imgur.com/a/p8Rg8PZ )

This is the monitor.app file from 5.14_1225 firmware for TL2/626.
So modified "/sys/block/mmcblk%c/device/serial" to "/mnt/secure/.sd_original_serial" (check screenshot, padded with a null byte).

2&3/ The ".sd_original_serial" was creating with the following command:
echo 0xaabbccdd > .sd_original_serial

When I have the SD in my computer, it is like that:

Code:
Disk /dev/sdd: 14.7 GiB, 15720251392 bytes, 30703616 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0a706388

Device     Boot    Start      End  Sectors   Size Id Type
/dev/sdd1        1009664 28606462 27596799  13.2G  b W95 FAT32
/dev/sdd2  *       73728   139263    65536    32M  6 FAT16
/dev/sdd3              1  1009664  1009664   493M 85 Linux extended
/dev/sdd4       28606464 30703615  2097152     1G 83 Linux
/dev/sdd5         139264   172031    32768    16M 83 Linux
/dev/sdd6         172032   204799    32768    16M 83 Linux
/dev/sdd7         204800   275455    70656  34.5M 83 Linux
/dev/sdd8         275456   776191   500736 244.5M 83 Linux
/dev/sdd9         776192   976895   200704    98M 83 Linux
/dev/sdd10        976896  1009663    32768    16M 83 Linux
/dev/sdd1 is the "user" partition
/dev/sdd2 is the boot partition (with what I guess is the kernel etc.)
/dev/sdd7 is the root partition (with /etc, linux userland)
/dev/sdd8 is ebrmain (it contains cramfs.img which in turn contains actual pocketbook programs like monitor.app, can be extracted with cramfsck).
/dev/sdd9 is the "secure" partition, mounted as /mnt/secure on pocketbook. This is where I put the .sd_original_serial file.
Code:
root@kali:/media/root/90ea7483-25c1-48ae-937c-b39d3b60b4e3# df -k .
Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/sdd9          97167 19473     72677  22% /media/root/90ea7483-25c1-48ae-937c-b39d3b60b4e3
root@kali:/media/root/90ea7483-25c1-48ae-937c-b39d3b60b4e3# ls -lA
total 1314
-rw-r--r-- 1 root            root             779270 Jul 11  2014 bootlogo.bmp
-rw-rw-rw- 1 systemd-resolve systemd-timesync      0 Jul  8 11:01 device.cfg
-rw-rw-rw- 1 root            root                 32 Jul 11  2014 deviceid
drwxrwx--- 2 systemd-resolve systemd-timesync   1024 Jul  5 16:08 dictionaries
-rw-r--r-- 1 root            root             524288 Jul 11  2014 explorer-2.tar
-r-------- 1 root            root                  4 Jan  1  2000 .freezestatus
-rwxr-xr-x 1 root            root                196 Jul 11  2014 fwinfo.txt
-rw-rw---- 1 systemd-resolve systemd-timesync     51 Jul  5 16:10 global.cfg
-rw-rw-rw- 1 systemd-resolve systemd-timesync     16 Jul 11  2014 .hashsum_1
-rw-r--r-- 1 root            root                 16 Jul  3 12:25 last_update
drwxrwxrwx 2 systemd-resolve systemd-timesync   1024 Jul  8 11:01 Legimi
drwxr-xr-x 2 root            root               1024 Jul  5 16:10 logo
drwxr-xr-x 2 root            root              12288 Jan  1  2000 lost+found
-rw-r--r-- 1 root            root                343 Jul 10  2016 man2wall.txt
-rw-rw-rw- 1 root            root                139 Jul 14 08:01 monitorinfo
-rw-r--r-- 1 root            root                 25 Jul 14 08:01 netdevcache
-rw-r--r-- 1 root            root                195 Jul  8 11:02 network.conf
drwxrwx--- 2 systemd-resolve systemd-timesync   1024 Oct 23  2013 pbpk
drwxrwxrwx 5 root            root               1024 Jul  5 18:20 pb_sshd5
drwxr-xr-x 2            1000             1000   1024 Jan  1  2000 ppbk
-rw-rw-rw- 1 root            root                  8 Oct  3  2015 reg.status
drwxrwxrwx 2 systemd-resolve systemd-timesync   1024 Jul  8 10:56 runonce
-rw-r--r-- 1 root            root                 11 Jul  8 10:08 .sd_original_serial
-rw-rw-rw- 1 systemd-resolve systemd-timesync      0 Jul  8 11:01 settings_pass.txt
-rwxrwx--- 1 systemd-resolve systemd-timesync     40 Jul  5 16:10 swupdate.db


For replacing the pocketbook link to monitor app, I went into /dev/sdd8, copied the patched version of monitor.app, moved the old link, and made a new one. I have this:
Code:
root@kali:/media/root/disk1# df -k .
Filesystem     1K-blocks   Used Available Use% Mounted on
/dev/sdd8         249983 200078     37388  85% /media/root/disk1
root@kali:/media/root/disk1# ls -l
total 127246
drwxr-xr-x  2 1028 users      2048 Jul 17  2017 adobefonts
drwxr-xr-x  2 1028 users      1024 Jul 17  2017 applications
drwxr-xr-x  2 1028 users      3072 Jul 17  2017 bin
drwxr-xr-x  4 1028 users      1024 Jul 17  2017 config
drwxr-xr-x  2 1028 users      1024 Jul 17  2017 cramfs
-rw-r--r--  1 1028 users 116277248 Jul 17  2017 cramfs.img
drwxr-xr-x 10 root root       1024 Jul  5 16:08 demo
drwxr-xr-x  3 1028 users      2048 Jul 17  2017 fonts
-rw-r--r--  1 1028 users      2623 Jul 17  2017 fsimage.md5
-rw-r--r--  1 1028 users    287713 Jul 17  2017 fsimage.tar.gz
drwxr-xr-x  4 1028 users      2048 Jul 17  2017 language
drwxr-xr-x  6 1028 users      8192 Jul 17  2017 lib
drwxr-xr-x  2 1028 users      1024 Jul 17  2017 libexec
drwxr-xr-x  2 1028 users      1024 Jul 17  2017 license
drwxr-xr-x  2 1028 users      1024 Jul 17  2017 logo
drwxr-xr-x  2 1028 users      1024 Jul 17  2017 logo2
drwx------  2 root root   12800000 Jul 17  2017 lost+found
-rwxr--r--  1 root root     387543 Jul  8 10:06 monitor.1225patched.app
lrwxrwxrwx  1 root root         23 Jul  8 10:06 pocketbook -> monitor.1225patched.app
lrwxrwxrwx  1 1028 users        15 Jul 17  2017 pocketbook.ORG -> bin/monitor.app
drwxr-xr-x  2 1028 users      1024 Jul 17  2017 sbin
drwxr-xr-x 17 1028 users      1024 Jul 17  2017 share
drwxr-xr-x  2 1028 users      1024 Jul 17  2017 themes
4/ Yes, I put the SD card back and everything is working.

To answer your final question, the original SD was 4 Gb, the new one is 16.
My user partition is 13+ Gb, and I have added a /dev/sdd4 ext2 partition to have native linux file system to play with (see fdisk -l output above).
I can't really explain the steps to make /dev/sdd1 bigger, I did not take notes for those steps.
I remember using fdisk to delete the old FAT32 partition and create the bigger one. Because of the strange partition layout I was not able to create it at the exact offset than the original. I am not sure if not respecting the value is important or not, but after creating it, I used a disk editor to patch the offset and restore the deleted partition start offset.

I also used fdisk to create the 1 Gb partition #4 which does not exist in original SD card layout.

I had no fear playing around like that since I have the SD card image to start over in case something wen wrong.

While the SD card was in my PC, I modified /etc/sudoers to allow everything, created a mnt/alt directory and modified /etc/fstab to automatically mount my etx2 partition inside it at system startup.
Code:
root@kali:/media/root/disk# cat etc/fstab
none			/proc		  proc	  defaults  0 0
none			/dev/pts	  devpts  mode=0622 0 0
tmpfs			/dev/shm	  tmpfs	  defaults  0 0
/dev/mmcblk0p4          /mnt/alt          auto    defaults  0 0
/dev/mmcblk0p8          /ebrmain          auto    ro        0 0
/dev/mmcblk0p9          /mnt/secure       auto    defaults  0 0
/ebrmain/cramfs.img	/ebrmain/cramfs	  auto	  defaults,loop 0 0


Edit: I could have put the .sd_original_serial file elsewhere, same with patched monitor.app, but this was done in a long process and made things like I felt. One thing you cannot avoid is modifying /dev/sdd8 to replace the link, or create a new cramfs.img and replace it (overkill in my opinion).
Now it is done, but if I had to start over again, I would place those two files in the new #4 partition.
This will not survive a firmware upgrade, but the device is "old" and I do not care.


I hope I have been clear enough and you will be able to extend your partition, I regret not having taken notes of this step.

Last edited by m4mmon; 07-14-2018 at 08:57 AM. Reason: remarks
m4mmon is offline   Reply With Quote