permanent changes to init.rc

4,135 views
Skip to first unread message

grou...@gmail.com

unread,
Dec 27, 2013, 11:10:30 PM12/27/13
to android-...@googlegroups.com
Hi,
 I want to modify init.rc file but changes to it are not remaining persistent. How do we make persistent changes to it? Please  help

Daniel Grießhaber

unread,
Dec 30, 2013, 2:32:51 PM12/30/13
to android-...@googlegroups.com

The rootdir is mounted as ramdisk, so you can't change the file in the device, you habe to change it in your build or image.

Am 30.12.2013 18:22 schrieb <grou...@gmail.com>:
Hi,
 I want to modify init.rc file but changes to it are not remaining persistent. How do we make persistent changes to it? Please  help

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dave Turvene

unread,
Dec 31, 2013, 2:17:09 PM12/31/13
to android-...@googlegroups.com
On Friday, December 27, 2013 11:10:30 PM UTC-5, grou...@gmail.com wrote:
Hi,
 I want to modify init.rc file but changes to it are not remaining persistent. How do we make persistent changes to it? Please  help

Yes, two ways (google search for specifics)

1)  From running boot.img

- retrieve boot.img from device using dd on the LNX partition
- use umkbootimg to explode it
- unzip initramfs and then cpio to get the default.prop, init.rc, init.trace.rc, etc.
- change desired files
- use mkbootimg to rebuild a RENAMED bootXX.img
- adb reboot bootloader
- fastboot boot ./bootXX.img to load the image without writing to flash
- IF it comes up, check to make sure props and init is run okay ELSE powercycle to boot flashed boot.img
- Once the new image is soaked write the new image to flash: fastboot flash boot bootXX.img

2) From local build area
- GIT clone the android area
- change the desired files, 
- do a "make bootimage" to build boot.img
- save the running boot.img as above
- follow steps above to fastboot your private image, soak it and then flash it.

It will help a lot for changing your init files to update props like ro.secure, ro.debuggable, service.adb

It's easier than it sounds and is *almost* always recoverable even after you flash the new bootXX.img BUT SAVE THE ORIGINAL boot.img!  Even then, Google or your device vendor will probably have a generic boot.img for your device.

Giveen

unread,
Dec 31, 2013, 2:55:27 PM12/31/13
to android-...@googlegroups.com
Which is what he was looking for information on how to....

Giveen

unread,
Jan 2, 2014, 1:58:12 PM1/2/14
to android-...@googlegroups.com
I think what he is more looking for is to make permanent changes to the build of the boot.img that include his prebuilt init.rc

Personally, I do this.

In your BoardConfig.mk
TARGET_PROVIDES_INIT_RC := true

Then in your device.mk include a product copy line for that file to the build directory, like this

PRODUCT_COPY_FILES += \
    $(LOCAL_PATH)/prebuilts/root/init.rc:root/init.rc

Dave Turvene

unread,
Jan 4, 2014, 1:04:33 PM1/4/14
to android-...@googlegroups.com
My interpretation is he's trying to make changes on a running system, but on reboot, the init.rc is overwritten from the ramdisk - this is a very common question.  The best way to make persistent changes to init.rc in a running boot.img is my method #1.

If he's building from aosp then he can modify the init.rc with the expectation the system may not come up - my caution about saving the pulled boot.img and soaking before writing to flash.  TARGET_PROVIDES_INIT_RC is a good way to override the default init.rc.  I follow the current convention of device.mk PRODUCT_COPY_FILES when I work on targets grouper or linaro/pandaboard.  LOCAL_PATH is okay but unnecessary, "prebuilts" should only be used for proprietary binaries or prebuilt distribution files.  Here's an example from the grouper device.mk:

 PRODUCT_COPY_FILES := \
     device/asus/grouper/fstab.grouper:root/fstab.grouper \
     device/asus/grouper/init.grouper.rc:root/init.grouper.rc \
     device/asus/grouper/init.rc:root/init.rc

Best to keep with the current pattern.

Reply all
Reply to author
Forward
0 new messages