Question

I am trying to modify the init.rc file on Nexus 7 device which is rooted. I want to insmod a simple hello world module before my /userdata/ partition is mounted. Things I have tried:

  1. Extracted the boot.img from the device, extracted the ramdisk, made changes to the init.rc (which do not work), recreated the boot.img (using mkbootimg tool) and then flashed it on the device again

  2. I have placed my hello.ko compiled for the kernel at 2 places: one is the current directory in which init.rc is placed, so that I can do something like insmod hello.ko and it will find it. Secondly, I created /lib/modules/ directory and placed it inside that

  3. In my init.rc I have placed the insmod /lib/modules/hello.ko right after on_boot. I have also changed the init.flo.rc and placed the insmod before and after ./mount_all which mounts the file system. However, I do not see my module loading at all. The permissions set were 0644 ( I tried with 0777 too)

  4. I created init.d inside /etc/folder and placed a loadmodule.sh which does an insmod /lib/modules/hello.ko and that module loads but once the boot process has completed.

I ideally want to do it right before mounting the /userdata/ partition.

Can someone help me with this?

My device is a Nexus 7, with flo_kernel and rooted, busybox installed, etc.

No correct solution

OTHER TIPS

The root filesystem on an Android device is "read-only", insofar that you cannot hang any files off the root tree and expect it to stay around. This is the same reason that you needed to extract the ramdisk and re-pack its contents in order to persist an init.rc change; any files you want to also locate at / must be packed into the ramdisk as well. Android extracts root from the ramdisk on every boot.

A more conventional location for that file would be on the system partition, say in /system/lib

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top