繁体   English   中英

在没有rootfs的情况下使用Bare initramfs

[英]Using Bare initramfs without rootfs

我正在尝试使用initramfs作为Linux内核引导的文件系统。 我希望我的文件系统最小,所以我只使用initramfs而没有rootfs。 现在,一旦内核启动,它就会从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

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM