- 论坛徽章:
- 0
|
我正在读《精通initramfs构建step by step》,在二十节的实验里遇到一个地方跳不过去,请大家帮忙分析一下。
/etc/inittab文件的内容是:- ::sysinit:/etc/init.d/rcS
- tty1::askfirst:/bin/sh
- tty2::askfirst:/bin/sh
- tty3::askfirst:/bin/sh
- tty4::askfirst:/bin/sh
- tty5::askfirst:/bin/sh
- tty6::askfirst:/bin/sh
- ::restart:/sbin/init
- ::ctrlaltdel:/sbin/reboot
- ::shutdown:/bin/umount -a -r
复制代码 /etc/init.d/rcS文件的内容是:- #!/bin/sh
- mount -t proc proc /proc
- mount -t sysfs sysfs /sys
- mdev -s
- mount /dev/sda8 /mnt
- exec switch_root /mnt /sbin/init
复制代码 init启动时读/etc/inittab文件,其中第一行告诉它去执行一个/etc/init.d/rcS脚本。rcS脚本的最后两行:先挂载硬盘上的根文件系统,然后调用switch_root命令切换到该文件系统。我的问题就出在switch_root的执行。在启动时屏幕上打印的信息:- BusyBox v1.19.2 (2011-10-22 16:15:41 CST) multi-call binary.
- Usage: switch_root [-c /dev/console] NEW_ROOT NEW_INIT [ARGS]
- Free initramfs and switch to another root fs:
- chroot to NEW_ROOT, delete all in /, move NEW_ROOT to /,
- execute NEW_INIT. PID must be 1. NEW_ROOT must be a mountpoint.
- Options:
- -c DEV Reopen stdio to DEV after switch
复制代码 似乎根文件系统没有切换成功,但也没有给出任何错误信息。提示信息在说:switch_root命令正确执行的前提是NEW_ROOT必须是挂载点,而且执行switch_root命令的必须是PID=1的进程。
1. 我cd到/mnt,并ls列目录内容,可以确认/dev/hda1设备确实挂载到/mnt。所以NEW_ROOT是挂载点没有问题。
2. 在rcS中用exec来执行switch_root命令,所以switch_root是在PID=1的进程中执行。
看来这两个条件都能满足,但为什么不能正确执行?请大家帮忙解决。谢谢了! |
|