Android 的 initrd.img 中包含什么?

发布于 2025-01-11 03:56:32 字数 180 浏览 4 评论 0原文

我用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傲娇萝莉攻 2025-01-18 03:56:32

这里简单解释一下android bootup和init

  • 在android bootup上,bootloader定位并加载linux
    核心。 Linux内核从启动进入用户空间
    内核空间使用内核中的 initramfs 功能。
  • ramdisk 本质上是一个包含所有内容的磁盘映像
    与设备的根文件系统相关联,本质上是“/”
    ' 目录。 initramfs 将 ramdisk 挂载到内存中(
    临时文件系统)。
  • 随后,initramfs 查找内存并加载并执行
    init 二进制文件。 ramdisk.img 有 C 文件,用于配置 init
    做 。
  • init是在用户空间中执行的第一个进程
    负责启动核心用户空间功能并
    跑步。
  • initrc 文件,负责配置 init 的内容
    实际上确实有一组运行在脚本上的指令
    某些事件触发(例如 init、fs、boot 时)。
  • init 继续运行并监视系统中的某些变化
    属性(触发器)。与这些相关的指令
    触发器在属性更改时执行。 (例如USB调试开/关)
  • 此外,init还执行称为服务的本机进程
    它们本质上是守护进程,例如 installd、logd、ueventd 等。init 还会重新启动可能退出/终止的服务。守护进程
    相互沟通和使用本地语言的能力有限
    从中读取和写入数据的套接字。

要进一步阅读,您可以参考此处 和这个 youtube 视频

Here's a brief explanation of android bootup and init

  • On android bootup , the bootloader locates and loads the linux
    kernel. The linux kernel boots into the userspace from the
    kernelspace using the initramfs functionality in the kernel.
  • The ramdisk is essentially a disk image that contains everything
    associated with the root filesystem of the device, essentially the '/
    ' directory. The initramfs mounts the ramdisk into memory ( a
    temporary filesystem ) .
  • Later, initramfs looks into the memory and loads and executes the
    init binary. The ramdisk.img has C files which configure what init
    does .
  • Init is the first process executed in the userspace which is
    responsible for getting the core userspace functionality up and
    running.
  • initrc files , the ones responsible for configuring what init
    actually does have set of instructions with scripts which run on
    certain event triggers ( such as on init, on fs, on boot).
  • init keeps on running and monitors the system for certain changes in
    the properties (triggers). Instructions associated with these
    triggers are executed upon change in the properties. (Such as USB Debugging on/off)
  • Additionally, init executes native processes called services
    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

痴者 2025-01-18 03:56:32

以下是 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文