【问题标题】:Using Bare initramfs without rootfs在没有 rootfs 的情况下使用 Bare initramfs
【发布时间】:2016-05-10 22:00:26
【问题描述】:

我正在尝试使用 initramfs 作为我的文件系统来启动 linux 内核。 我希望我的文件系统最小,所以我只使用没有 rootfs 的 initramfs。现在一旦内核启动它从 initramfs 执行 /init,我尝试在 init 中挂载 proc 和 sysfs,如下所示。

#!/bin/busybox sh
echo "Mounting Proc and Sysfs"
# Mount the /proc and /sys filesystems.
mount -t proc none /proc
mount -t sysfs none /sys

我还需要添加什么才能使用 initramfs 获取命令提示符。当我执行上面的 init 命令时出现以下错误。

New FileSystem
Mounting Proc and Sysfs
This script just
[    4.524724] sh (116) used greatest stack depth: 13832 bytes left mounts and boots the rootfs, nothing else!
[    4.537448] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000
[    4.537448]
[     4.537453] CPU: 0 PID: 1 Comm: init Not tainted 4.1.17-ltsi-rt18 #4

【问题讨论】:

  • 请修正您的格式

标签: linux


【解决方案1】:

您的问题是您的 shell 脚本(又名“init”)退出了。内核将不会运行超过 PID 1 退出点。常规的初始化序列通过使用 exceve 抛出 PID 1 来解决这个问题(即 - initramfs 中的 init 调用 exceve 以切换到根文件系统中的 init,等等)。

我建议在初始化结束时添加对 /bin/sh(bash、zsh 等)的调用,然后调用 shutdown(这样如果 shell 退出,系统就会停止)。这将为您提供一些可用的 shell。

此外,由于您似乎已经在使用busybox,它有一个非常有用的init 实现。您可以使用它来启动实际的初始化序列,使用带有实际 TTY 控制的实际 shell。

【讨论】:

    猜你喜欢
    • 2013-02-08
    • 2021-10-30
    • 2021-12-01
    • 2010-12-09
    • 2018-03-02
    • 2019-06-20
    • 2014-10-07
    • 2018-04-08
    • 2011-10-26
    相关资源
    最近更新 更多