I want to change the init.rc
file of an android pad. But after I change it and reboot the system, the original init.rc
comes back.
我想要改变init。rc文件的android pad。但在我改变它并重启系统后,初始的init。rc回来。
How can I make the change to the init.rc
persistently without rebuild the system (since I don't have the source code of the system)? Or is there any way to work around?
如何对init进行更改。不需要重新构建系统(因为我没有系统的源代码)?或者有什么方法可以解决吗?
13
Unpack the uramdisk using following command in host PC(Linux)
在主机PC(Linux)中使用以下命令解压uramdisk
mkdir /tmp/initrc cd /tmp/initrd
sudo mount /dev/sdb1 /mnt
sdb1
is partion where uramdisk/uInitrd
resides.
sdb1是uramdisk/uInitrd所在的地方。
dd bs=1 skip=64 if=/mnt/uInitrd of=initrd.gz
gunzip initrd.gz
At this point running the command file initrd
should show:
此时运行命令文件initrd应该显示:
mkdir fs
cd fs
cpio -id <../initrd
Make changes to init.rc
更改init.rc
Pack uramdisk using following commands:
使用以下命令装入uramdisk:
find ./ | cpio -H newc -o > ../newinitrd
cd ..
gzip newinitrd
mkimage -A arm -O linux -C gzip -T ramdisk -n "My Android Ramdisk Image" -d newinitrd.gz uInitrd-new
11
Try this site: http://bootloader.wikidot.com/linux:boot:android Read the section at the bottom: •The Android boot image: boot.img ◦Unpack, re-pack boot image: http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack%2C_Edit%2C_and_Re-Pack_Boot_Images#Background
试试这个网站:http://bootloader.wikidot.com/linux:boot:android阅读下面的部分:•android启动镜像:boot。img◦解压,re-pack引导映像:http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack % 2 c_edit % 2 c_and_re-pack_boot_images #背景
10
A number of Android devices include code to prevent root modifications to the system files. The way this is done is by using the recovery partition. On reboot, they basically restore the system partition using the recovery image. If your system is doing that then you cannot make persistent changes - the best you could do would be to hook up something to run after reboot to re-apply your change. In CyanogenMod they had hooks in the init.rc to run sdcard scripts if found. Perhaps you can create an app or widget to then launch a script to make the mods required using a setuid root script from the data partition. Without building your own ROM you are quite restricted in this area.
一些Android设备包括代码,以防止对系统文件的根修改。这是通过使用恢复分区来完成的。在重新启动时,他们基本上使用恢复映像恢复系统分区。如果您的系统正在这样做,那么您就不能进行持久的更改——您所能做的最好的事情就是在重新启动后连接一些东西以重新应用您的更改。在CyanogenMod中,他们在init中有钩子。如果找到的话,可以运行sdcard脚本。也许您可以创建一个应用程序或小部件,然后启动一个脚本,以从数据分区中使用setuid根脚本生成所需的mods。如果不建立你自己的ROM,你在这个领域就会受到很大的限制。
Possibly you could fetch the recovery image and try unpacking that, making your changes and repacking and flashing it. But make sure you can recover with fastboot before you try this.
可能您可以获取恢复映像并尝试打开它,使您的更改和重新打包并闪烁。但在你尝试之前,确保你能快速恢复。
9
When an android system boots, uboot unpacks a special compressed ball of files in your boot partition called 'uRamdisk' to RAM, and defines those files to comprise the root directory of the system. uRamdisk normally contains a bunch of directories (system, data, media, etc.) that serve as mountpoints for partitions that contain the files that go in them, but also has some very basic files vital to your system, including the init binary and startup scripts like init.rc.
当一个android系统启动时,uboot将一个特殊的压缩包的文件包在您的引导分区中,称为“uRamdisk”到RAM,并定义这些文件组成系统的根目录。uRamdisk通常包含一堆目录(系统、数据、媒体等),这些目录可以作为包含文件的挂载点,但也有一些非常基本的文件对您的系统至关重要,包括init二进制文件和启动脚本(如init.rc)。
when you edit the init.rc, you've actually just edited the unpackaged copy of init.rc that resides in your RAM. To really change it then, you have to copy your uRamdisk, extract it, edit the init.rc from there, repackage uRamdisk and then replace the new one with the old one in /boot.
当你编辑init。rc,你刚刚编辑了init的未打包拷贝。驻留在您的RAM中的rc。要真正改变它,你必须复制你的uRamdisk,提取它,编辑init。从那里,重新包装uRamdisk,然后替换旧的一个在/boot。
Try looking up the 'xuramdisk' and 'mkuramdisk' scripts, these make the process very simple.
尝试查找“xuramdisk”和“mkuramdisk”脚本,这使得过程非常简单。
4
I don't know if you are still trying to do this but without knowing your exact device nobody can give you an exact answer.
我不知道你是否还在试着这样做但是不知道你的精确设备没人能给你一个确切的答案。
Try taking a dd image
of all your internal partitions and use some scripts like those included with android kitchen on xda forums. Your recovery and boot partitions will both have a ram disk but odds are you want to modify the init.rc
in the boot.img
not recovery, unless you only want the changes present in recovery mode.
尝试对所有内部分区进行dd映像,并使用一些脚本,比如在xda论坛上使用android厨房的脚本。您的恢复和引导分区都有一个ram磁盘,但是您希望修改init。rc引导。img没有恢复,除非您只希望在恢复模式中出现更改。
The unyaffs thing doesn't apply to all devices and most devices have different partition layouts so you have to figure out which is boot and what type of fs it is. Maybe if you give your device specs you can get a better answer.
unyaffs的东西并不适用于所有设备,大多数设备都有不同的分区布局,所以你必须弄清楚哪些是引导,哪些类型是fs。也许如果你给你的设备规格,你可以得到一个更好的答案。
4
Your root partition (where /init.rc lives) is a ramdisk which is unpacked from an initrd file and mounted every time your device boots. Any changes you make are to the ramdisk only, and will be lost on the next reboot.
根分区(其中/init)。rc lives)是一个ramdisk,它从initrd文件中解压,并在每次您的设备引导时安装。您所做的任何更改都只针对ramdisk,并且将在下一次重新启动时丢失。
If you can get the initrd file, you can mount it on your Linux host system, modify the files there, unmount it, and write it back to your Android.
如果您可以获得initrd文件,您可以在您的Linux主机系统上安装它,修改那里的文件,卸载它,并将它写回您的Android。
The initrd file exists in its own partition on the device. If you can figure out which partition it is, you can grab it from the device onto your host, mount it, modify it, and write it back to the device. This is what tripler was talking about above.
initrd文件存在于设备本身的分区中。如果你能找出它是哪个分区,你可以从设备上抓取它到你的主机上,安装它,修改它,然后把它写回设备。这就是tripler所说的。
In general, modifying boot.img is something that only system developers do. If you're building the entire Android system, you'll have access to the necessary source code. My workflow for this looks like this:
一般来说,修改启动。img是只有系统开发人员才会做的事情。如果您正在构建整个Android系统,您将可以访问必要的源代码。我的工作流程是这样的:
# Modify init.rc
m -j8 bootimage_signed
adb reboot bootloader
fastboot flash boot $OUT/boot.img
fastboot reboot
0
Please note that it may be easier for you to use an app like Scripter to run a script at boot time than modify this file.
请注意,您可能更容易使用像Scripter这样的应用程序在引导时运行脚本,而不是修改该文件。
Before following @tripler's instructions above you need a file called boot.img
which can be extracted by (run on rooted Android device, untested without root):
在使用@tripler的指令之前,您需要一个名为boot的文件。img可以通过(运行在root Android设备上,未经root用户测试):
dd if=/dev/block/platform//by-name/boot of=/sdcard/boot.img
Then connect your Android to your computer and copy the boot.img
file from there.
然后将你的安卓系统连接到你的电脑上,并复制启动。img文件。
Script:
脚本:
http://linuxclues.blogspot.ca/2012/11/split-bootimg-python-android.html
http://linuxclues.blogspot.ca/2012/11/split-bootimg-python-android.html
Here is a modified, easier to see version of tripler's instructions (assuming boot.img
is in tmp):
这里有一个修改过的,更容易看到的版本的tripler的指令(假设启动。img在tmp):
cd /tmp
mkdir fs
# Now use the linked script above to split the boot.img file into ramdisk.gz and kernel
python split_boot_img.py -i boot.img -o parts
cd fs
gunzip -c ../parts/ramdisk.gz | cpio -id
# make changes to init.rc
At that point you will have to rebuild the boot.img
back together before reflashing, which will be device-specific. Can't help you with that, sorry!
在这一点上,您将不得不重新构建启动。在反流之前,将img重新组合在一起,这将是设备专用的。我帮不了你,对不起!
-3
You have to edit/change the init.rc
before building your Android pad file system. This is the preferred way, and always works.
你必须编辑/修改init。在构建Android pad文件系统之前。这是最好的方法,而且总是有效。