Android 的 initrd.img 中包含什么?
我用 cat initrd.img | 解压了 initrd.img枪拉链 | cpio -vid
然后有一个名为 init
的可执行文件,我认为这是内核运行的第一件事。然而,它有什么作用呢?有没有一个我可以在 google AOSP 源代码上查看的示例,以便我有一个想法?这个应该是小米修改的
I unpacked the initrd.img with cat initrd.img | gunzip | cpio -vid
and then there's an executable called init
which I think is the first thing the kernel runs. However, what does it do? Is there an example of one that I can look on google AOSP source so I have an idea? This one is likely modified by Xiaomi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里简单解释一下android bootup和init
核心。 Linux内核从启动进入用户空间
内核空间使用内核中的 initramfs 功能。
与设备的根文件系统相关联,本质上是“/”
' 目录。 initramfs 将 ramdisk 挂载到内存中(
临时文件系统)。
init 二进制文件。 ramdisk.img 有 C 文件,用于配置 init
做 。
负责启动核心用户空间功能并
跑步。
实际上确实有一组运行在脚本上的指令
某些事件触发(例如 init、fs、boot 时)。
属性(触发器)。与这些相关的指令
触发器在属性更改时执行。 (例如USB调试开/关)
它们本质上是守护进程,例如 installd、logd、ueventd 等。init 还会重新启动可能退出/终止的服务。守护进程
相互沟通和使用本地语言的能力有限
从中读取和写入数据的套接字。
要进一步阅读,您可以参考此处 和这个 youtube 视频
Here's a brief explanation of android bootup and init
kernel. The linux kernel boots into the userspace from the
kernelspace using the initramfs functionality in the kernel.
associated with the root filesystem of the device, essentially the '/
' directory. The initramfs mounts the ramdisk into memory ( a
temporary filesystem ) .
init binary. The ramdisk.img has C files which configure what init
does .
responsible for getting the core userspace functionality up and
running.
actually does have set of instructions with scripts which run on
certain event triggers ( such as on init, on fs, on boot).
the properties (triggers). Instructions associated with these
triggers are executed upon change in the properties. (Such as USB Debugging on/off)
which are essentially daemons such as installd, logd, ueventd etc. init also restarts services that may exit/killed. Daemon processes
have limited ability to communicate to each other and use local
sockets to read and write data from.
To read further you can refer here and this youtube video
以下是 AOSP 初始化源(包括自述文件)的链接:https:// /android.googlesource.com/platform/system/core/+/master/init/
如果您正在寻找二进制文件,您也许可以从 Google Pixel ROM 中提取它。
不过,使用
binwalk
快速查看沿袭初始化二进制文件并没有提供太多信息。如果您希望初始 ramdisk 中包含更多文件,则早期版本的 Android 中包含的许多文件已移至
/system/vendor/etc/
下的 system.img 中Here is the link to the AOSP init sources including readme: https://android.googlesource.com/platform/system/core/+/master/init/
If you are looking for a binary you might be able to extract it e.g. from a Google Pixel ROM.
A quick look with
binwalk
into a lineage init binary did not provide too much information though.In case you were expecting more files in your initial ramdisk, many files which had been included in earlier versions of android have been moved into the system.img under
/system/vendor/etc/