热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

对init进行持久更改。-Makepersistentchangestoinit.rc

Iwanttochangetheinit.rcfileofanandroidpad.ButafterIchangeitandrebootthesystem,th

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进行更改。不需要重新构建系统(因为我没有系统的源代码)?或者有什么方法可以解决吗?

8 个解决方案

#1


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

#2


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 #背景

#3


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.

可能您可以获取恢复映像并尝试打开它,使您的更改和重新打包并闪烁。但在你尝试之前,确保你能快速恢复。

#4


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”脚本,这使得过程非常简单。

#5


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。也许如果你给你的设备规格,你可以得到一个更好的答案。

#6


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

#7


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重新组合在一起,这将是设备专用的。我帮不了你,对不起!

#8


-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文件系统之前。这是最好的方法,而且总是有效。


推荐阅读
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • 嵌入式处理器的架构与内核发展历程
    本文主要介绍了嵌入式处理器的架构与内核发展历程,包括不同架构的指令集的变化,以及内核的流水线和结构。通过对ARM架构的分析,可以更好地理解嵌入式处理器的架构与内核的关系。 ... [详细]
  • VScode格式化文档换行或不换行的设置方法
    本文介绍了在VScode中设置格式化文档换行或不换行的方法,包括使用插件和修改settings.json文件的内容。详细步骤为:找到settings.json文件,将其中的代码替换为指定的代码。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 本文介绍了九度OnlineJudge中的1002题目“Grading”的解决方法。该题目要求设计一个公平的评分过程,将每个考题分配给3个独立的专家,如果他们的评分不一致,则需要请一位裁判做出最终决定。文章详细描述了评分规则,并给出了解决该问题的程序。 ... [详细]
  • 成功安装Sabayon Linux在thinkpad X60上的经验分享
    本文分享了作者在国庆期间在thinkpad X60上成功安装Sabayon Linux的经验。通过修改CHOST和执行emerge命令,作者顺利完成了安装过程。Sabayon Linux是一个基于Gentoo Linux的发行版,可以将电脑快速转变为一个功能强大的系统。除了作为一个live DVD使用外,Sabayon Linux还可以被安装在硬盘上,方便用户使用。 ... [详细]
  • SpringBoot整合SpringSecurity+JWT实现单点登录
    SpringBoot整合SpringSecurity+JWT实现单点登录,Go语言社区,Golang程序员人脉社 ... [详细]
  • 本文介绍了C++中省略号类型和参数个数不确定函数参数的使用方法,并提供了一个范例。通过宏定义的方式,可以方便地处理不定参数的情况。文章中给出了具体的代码实现,并对代码进行了解释和说明。这对于需要处理不定参数的情况的程序员来说,是一个很有用的参考资料。 ... [详细]
  • 3.223.28周学习总结中的贪心作业收获及困惑
    本文是对3.223.28周学习总结中的贪心作业进行总结,作者在解题过程中参考了他人的代码,但前提是要先理解题目并有解题思路。作者分享了自己在贪心作业中的收获,同时提到了一道让他困惑的题目,即input details部分引发的疑惑。 ... [详细]
  • 深度学习中的Vision Transformer (ViT)详解
    本文详细介绍了深度学习中的Vision Transformer (ViT)方法。首先介绍了相关工作和ViT的基本原理,包括图像块嵌入、可学习的嵌入、位置嵌入和Transformer编码器等。接着讨论了ViT的张量维度变化、归纳偏置与混合架构、微调及更高分辨率等方面。最后给出了实验结果和相关代码的链接。本文的研究表明,对于CV任务,直接应用纯Transformer架构于图像块序列是可行的,无需依赖于卷积网络。 ... [详细]
  • 海马s5近光灯能否直接更换为H7?
    本文主要介绍了海马s5车型的近光灯是否可以直接更换为H7灯泡,并提供了完整的教程下载地址。此外,还详细讲解了DSP功能函数中的数据拷贝、数据填充和浮点数转换为定点数的相关内容。 ... [详细]
  • 本文分析了Wince程序内存和存储内存的分布及作用。Wince内存包括系统内存、对象存储和程序内存,其中系统内存占用了一部分SDRAM,而剩下的30M为程序内存和存储内存。对象存储是嵌入式wince操作系统中的一个新概念,常用于消费电子设备中。此外,文章还介绍了主电源和后备电池在操作系统中的作用。 ... [详细]
author-avatar
为你空手的执着
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有