View Single Post
Old 01-27-2012, 07:57 AM   #14
j0534ng31
Connoisseur
j0534ng31 can extract oil from cheesej0534ng31 can extract oil from cheesej0534ng31 can extract oil from cheesej0534ng31 can extract oil from cheesej0534ng31 can extract oil from cheesej0534ng31 can extract oil from cheesej0534ng31 can extract oil from cheesej0534ng31 can extract oil from cheesej0534ng31 can extract oil from cheese
 
Posts: 83
Karma: 1224
Join Date: Dec 2011
Location: Gijon (Spain)
Device: Sony PRS-T1 black
Post

¿What do you think about this approach?

In init.rc, 'preload' is mounted before 'system' and 'data':
Code:
# mount ext4 partitions
    mount ext4 /dev/block/mmcblk2p6 /ebook/dic ro
    mount ext4 /dev/block/mmcblk2p8 /ebook/preload ro

    mount ext4 /dev/block/mmcblk2p10 /system
    mount ext4 /dev/block/mmcblk2p10 /system ro remount

    # We chown/chmod /data again so because mount is run as root + defaults
    mount ext4 /dev/block/mmcblk2p9 /data nosuid nodev
    chown system system /data
    chmod 0771 /data
    chown system system /data/app
Then, I think we can put our tools (e2fsck) into a new directory in 'preload' and change the PATH variable; and so, system and data can be automatically checked at boot time, just before mounting them.

As there is no free space in preload, but there is unused space in /dev/block/mmcblk2p8, first of all we have to resize the filesystem.

While booted in normal mode:
Code:
/ # # Just for your information, to see my actual busybox version
/ # # It's a full version, completely installed in '/system/xbin'
/ # busybox
BusyBox v1.20.0.git (2011-12-11 18:10:48 CET) multi-call binary.

/ # # To see actual size of preload and free space
/ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
...
/dev/block/mmcblk2p8     36708     36697        11 100% /ebook/preload
...

/ # # Making a image of preload
/ # dd if=/dev/block/mmcblk2p8 of=/extsd/mmcblk2p8.img
81968+0 records in
81968+0 records out
41967616 bytes (40.0MB) copied, 14.361208 seconds, 2.8MB/s

/ # # Just to be sure
/ # stat -c %s /extsd/mmcblk2p8.img
41967616

/ # # Umount preload to resize fs
/ # umount /ebook/preload

/ # # Resizing the preload fs to partition size
/ # resize2fs /dev/block/mmcblk2p8
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/block/mmcblk2p8 to 40984 (1k) blocks.
The filesystem on /dev/block/mmcblk2p8 is now 40984 blocks long.

/ # # Remount the new preload
/ # mount /dev/block/mmcblk2p8 /ebook/preload

/ # # To see actual size of preload and free space
/ # df  &&  df -h
Filesystem           1K-blocks      Used Available Use% Mounted on
...
/dev/block/mmcblk2p8     40947     36697      4250  90% /ebook/preload
...
/dev/block/mmcblk2p8     40.0M     35.8M      4.2M  90% /ebook/preload
...
So, now we have 4.2MB... to save our tools and perhaps some scripts.

We just have to:
  1. Remount '/ebook/preload' as read/write
    mount -o remount,rw /dev/block/mmcblk2p8

  2. Create a new directory '/ebook/preload/bin'
    mkdir /ebook/preload/bin

  3. Copy there our 'e2fsck' tool
    cp -p $(which e2fsck) /ebook/preload/bin
    chmod 755 /ebook/preload/bin/e2fsck

  4. Option 1: Call 'e2fsck' from 'init.rc' using absolute path, to check filesystems at boot.

    - If needed, not forced, seems right to me:
    /ebook/preload/bin/e2fsck -py /dev/block/mmcblk2p9
    /ebook/preload/bin/e2fsck -py /dev/block/mmcblk2p10

    - Always, forced, seems of little use to me:
    /ebook/preload/bin/e2fsck -pyf /dev/block/mmcblk2p9
    /ebook/preload/bin/e2fsck -pyf /dev/block/mmcblk2p10

  5. Option 2: Add '/ebook/preload/bin' to the PATH variable (in 'init.rc') and let the system to decide when to do the check
    So, new PATH=/sbin:/system/sbin:/system/bin:/system/xbin:/ebook/preload/bin
    mount -o remount,rw /
    sed -i '/export PATH/ s@$@:/ebook/preload/bin@' /init.rc

  6. We can also change the automatic check frequency:
    tune2fs -c max_mounts_count /dev/block/mmcblk2p9
    tune2fs -c max_mounts_count /dev/block/mmcblk2p10

  7. Write pending changes to disk and reboot in normal mode:
    sync && $(which chgboot) normal && reboot


Just for the sake of completeness, right here are the tools I'm using (ready to download):
  • e2fsck
  • resize2fs
  • tune2fs
  • busybox (used for every other command)
    Install it, or replace every busybox depending 'command' by 'busybox command'
  • parted (NOT USED: I owe it to uboot!)



PS1:

I've used the same 'stat' + 'tune2fs' approach to extend the system partition.
(but, from recovery mode, to can umount the 'system' filesystem.)

It seems to me a 'cleaner' method than creating a new image, copying old system to new image,...


PS2:

I'm doing a great effort of documenting every procedure used to modify the PRS-T1 in a thread of my spanish forum...
I'm explaining how to use the android SDK, a bit of Linux, and a lot of interesting procedures like how to do a manual rooting, what is and how to install busybox,...
It needs to be borne in mind that it is a non-technical people forum; many of them are only book lovers,... so the information is written kinda adapted to their comprehesion skills.

It's in spanish language but using english is quite in order, so there is no need to translate with to post.
Those interested in taking part can find it HERE. You are very welcome!

Last edited by j0534ng31; 01-27-2012 at 08:02 AM.
j0534ng31 is offline   Reply With Quote