01-25-2012, 08:37 AM | #1 |
Evangelist
Posts: 425
Karma: 75216
Join Date: Nov 2011
Location: old europe
Device: Kobo Mini, Tolino Epos 2
|
HOWTO: e2fsck on init, fix_permissions afterwards
Hi folks, especially the devs,
I am desperately trying to get e2fsck fix my data and system partitions before mount and also run fix_permissions on every boot. Both filesystems may get corrupted on a crash or cold reset. (I know that system is mounted read only normally, but it can be remounted rw for tweaking purposes, you know? ) The result of such a corruption are lots of force close popups and apps forgetting about their settings which many of us occassionally run into. (https://www.mobileread.com/forums/sho...d.php?t=164020 https://www.mobileread.com/forums/sho...d.php?t=164564) Anyways, I already got a working e2fsck binary and found out that the whole boot process is done by the /init binary running the /init.rc script. Read here for details: http://www.kandroid.org/online-pdk/guide/bring_up.html So, the first thing to be done is integrating e2fsck commands into init.rc. But this requires the e2fsck binary to be available at this stage. Any ideas? The best thing would be a busybox binary with integrated e2fsck. But I haven't found one for ARM yet... The one I have is statically linked to EXT2FS library, got it from here: http://sites.google.com/site/juanjosec/android But how to make it available during init? Integrate to uboot / initial ramdisk? The second goal - running the fix_permissions script - could be achieved by putting an exec call to /etc/install-recovery.sh, which is automatically called by /init.rc when the "on init" section is finished. I tried many different ways to make install-recovery.sh run fix_permissions, but no success: Code:
/bin/fix_permissions exec /system/bin/fix_permissions exec /system/bin/sh /system/bin/fix_permissions Code:
echo test > /mnt/sdcard/test.log /system/bin/busybox echo test > /mnt/sdcard/test.log write /mnt/sdcard/test.log test |
01-25-2012, 08:53 AM | #2 |
Zealot
Posts: 102
Karma: 38810
Join Date: Apr 2011
Device: Sony PRS-T1
|
hi, in a linux system, you can set the frequency of checking the filesystems with fsck, if it is what you mean, with tune2fs and -c option..
i.e. tune2fs -c 1 /dev/block/mmcblk2p10 (1 or 0, I don't remember) the setting should be written in the partition, so you can launch the command only one time wherever you want. does dmesg say something about install_recovery? I don't understand why you have to run fsck on every boot. It should be enough to run it one time only. |
Advert | |
|
01-25-2012, 08:57 AM | #3 |
Evangelist
Posts: 425
Karma: 75216
Join Date: Nov 2011
Location: old europe
Device: Kobo Mini, Tolino Epos 2
|
The point is: on some android devices, especially the T1, there will NEVER be fsck done, regardless of the sanity state of the filesystems!
This is because: 1.) There are no fsck binaries for ext2/3/4 installed 2.) There are no fsck calls in init.rc So, dmesg says something like Code:
<4>EXT4-fs (mmcblk2p10): warning: mounting unchecked fs, running e2fsck is recommended |
01-25-2012, 10:29 AM | #4 |
Zealot
Posts: 102
Karma: 38810
Join Date: Apr 2011
Device: Sony PRS-T1
|
well,
it seems that sdcard is not accessible when install-recovery is launched. Try this (for me it works): mkdir /tmp echo test > /tmp/test obviously the file is accessible only until the T1 is rebooted again |
01-25-2012, 04:09 PM | #5 |
Member
Posts: 14
Karma: 20
Join Date: Dec 2011
Device: Sony Reader PRS-T1
|
I think the best way would be to add e2fsck to the ramdisk and create an entry in the init.rc config.
|
Advert | |
|
01-25-2012, 04:30 PM | #6 |
Zealot
Posts: 102
Karma: 38810
Join Date: Apr 2011
Device: Sony PRS-T1
|
yeah, but it requires to flash p1 or p2 partitions (they're read only), which is quite dangerous.. the best way is to use a script that is stored in the /system (ext4) partition, so we can modify easily with adb.
install-recovery works fine for me |
01-25-2012, 04:40 PM | #7 |
Member
Posts: 14
Karma: 20
Join Date: Dec 2011
Device: Sony Reader PRS-T1
|
yeah but in order to run e2fsck successfully it needs to be executed before the /system /data etc partition are mounted otherwise it wont work, so imho the only option is to put in init.rc of the ramdisk.
|
01-25-2012, 04:42 PM | #8 |
Zealot
Posts: 102
Karma: 38810
Join Date: Apr 2011
Device: Sony PRS-T1
|
oh, you are right.. I didn't think of that :P
|
01-25-2012, 04:56 PM | #9 |
Member
Posts: 14
Karma: 20
Join Date: Dec 2011
Device: Sony Reader PRS-T1
|
However for the fix_permissions script install-recovery.sh is the best location.
Adding "sh /system/bin/fix_permissions 2>&1 > /data/fix_permissions.log" to install-recovery.sh works like a charm Last edited by S3raph; 01-27-2012 at 10:42 AM. |
01-25-2012, 06:55 PM | #10 | |
meat popsicle
Posts: 225
Karma: 100000
Join Date: Jul 2007
Location: USA
Device: Kindles, Pixels, iPads
|
Quote:
Or you are talking about fixing file systems only? |
|
01-25-2012, 07:00 PM | #11 |
Zealot
Posts: 102
Karma: 38810
Join Date: Apr 2011
Device: Sony PRS-T1
|
e2fsck fix the file system, not the permissions. For the permission part, we have to run fix_permissions after the system and data are mounted
|
01-26-2012, 04:00 AM | #12 |
Evangelist
Posts: 425
Karma: 75216
Join Date: Nov 2011
Location: old europe
Device: Kobo Mini, Tolino Epos 2
|
Thanks @S3raph!!
@rupor: install_recovery is run as a service and at the point where services are started, everything is mounted |
01-26-2012, 12:11 PM | #13 |
Member
Posts: 14
Karma: 20
Join Date: Dec 2011
Device: Sony Reader PRS-T1
|
Your welcome
by the way I asked porkupan the correct parameters to build a "new" ramdisk Code:
find . -print | cpio -o -H newc | gzip -v9 > ../ramdisk-adb.gz mkimage -A ARM -O Linux -T ramdisk -C gzip -a 0x70308000 -e 0x70308000 -n "Normal Rootfs" -d ramdisk-adb.gz ramdisk-adb.uimg |
01-27-2012, 07:57 AM | #14 |
Connoisseur
Posts: 83
Karma: 1224
Join Date: Dec 2011
Location: Gijon (Spain)
Device: Sony PRS-T1 black
|
¿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 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 ... We just have to:
Just for the sake of completeness, right here are the tools I'm using (ready to download):
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. |
01-27-2012, 10:32 AM | #15 |
Member
Posts: 14
Karma: 20
Join Date: Dec 2011
Device: Sony Reader PRS-T1
|
great idea j0534ng31 I didn't thought about that, however the probably greatest advantage of the ramdisk solution is its simplicity.
I attached my modified ramdisk, its the "normal" ramdisk with a modified init.rc and includes the e2fsck binary. Code:
# check filesystem exec /sbin/e2fsck -py /dev/block/mmcblk2p1 exec /sbin/e2fsck -py /dev/block/mmcblk2p9 exec /sbin/e2fsck -py /dev/block/mmcblk2p10 [EDIT] IF YOU HAVE DOWNLOADED ANY OF THE FILES DONT FLASH IT, IT WILL BRICK YOUR READER/RAMDISK. YOU CAN RESTORE IT WITH THE SD-RESCUE METHOD [EDIT] Last edited by S3raph; 01-29-2012 at 11:36 AM. |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cannot edit init.rc | sjkevin | Nook Developer's Corner | 4 | 02-15-2011 06:44 PM |
web2disk - howto? | urbane_gorilla | Calibre | 3 | 03-29-2010 04:48 AM |
SmartQ5 - modem init string and login data saving | Drakon Rider | Alternative Devices | 4 | 09-27-2009 05:09 AM |
Howto open case? | Flolo | HanLin eBook | 7 | 06-25-2009 04:11 AM |
update howto | m-s-s | iRex | 5 | 07-01-2007 03:52 PM |