的确:
dracut
initramfs。rd.break
在内核命令行上添加一个选项来引导到 initramfs shell 。cd /sysroot
usr/bin/pivot_root . mnt
- >pivot_root
失败,“无效参数”,对应于errno
的值EINVAL
。
对此没有解释man 2 pivot_root
:
EINVAL
put_old不在new_root之下。
为什么会失败?正如下一个评论者回答的那样,“那么 Linux 将如何退出早期用户空间?”
与 不同的是initrd
,Linux 不允许卸载initramfs
. 显然这有助于保持内核代码简单。
pivot_root
您可以使用该switch_root
命令代替。它执行以下过程。 请注意,switch_root
删除旧根目录上的所有文件,以释放 initramfs 内存,因此您需要小心运行此命令的位置。
initramfs 是 rootfs:您既不能 pivot_root rootfs,也不能卸载它。而是删除 rootfs 中的所有内容以释放空间(find -xdev / -exec rm '{}' ';'),使用新根目录重载 rootfs(cd /newmount; mount --move . /; chroot .),将 stdin/stdout/stderr 附加到新的 /dev/console,并执行新的 init。
请注意,建议的 shell 命令只是 C 代码的粗略等效项。除非它们都内置到您的 shell 中,否则这些命令将不会真正起作用,因为第一个命令会从 initramfs 中删除所有程序和其他文件:-)。
Rootfs 是 ramfs(或 tmpfs,如果已启用)的一个特殊实例,它始终存在于 2.6 系统中。您无法卸载 rootfs 的原因与您无法终止 init 进程的原因大致相同;与使用特殊代码来检查和处理空列表相比,内核确保某些列表不会变空更小更简单。
https://github.com/torvalds/linux/blob/v4.17/Documentation/filesystems/ramfs-rootfs-initramfs.txt
归档时间: |
|
查看次数: |
4039 次 |
最近记录: |