簡體   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