[projects/geninitrd] sleep before switch_root is about to fail
glen
glen at pld-linux.org
Tue Dec 24 01:25:08 CET 2013
commit 0273c2c4aa93f2c066f64adac9a494495d471e6a
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Tue Dec 24 02:23:20 2013 +0200
sleep before switch_root is about to fail
as "exec" never returns, switch_root will be last command on initrd
and also as switch_root needs to be ran as pid 1, there's no other way
than to sleep before switch_root followed by kernel panic
geninitrd | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/geninitrd b/geninitrd
index ff0d958..fdca56b 100755
--- a/geninitrd
+++ b/geninitrd
@@ -944,11 +944,24 @@ initrd_gen_initramfs_switchroot() {
EOF
umount_all
- busybox_applet switch_root
+ busybox_applet switch_root usleep
add_linuxrc <<-'EOF'
[ ! -e /newroot/dev/console ] && mknod -m 660 /newroot/dev/console c 5 1
+
+ # switch root to empty dir will make kernel panic, so sleep 10s before it
+ # switch_root needs to be pid 1, so there's no other way to recover from here
+ # if /dev is missing, switch root will likely fail, give debug shell before that
+ if [ ! -d /newroot/dev ]; then
+ echo "/dev is missing, switch_root will likely fail"
+ echo "if you booted with debugrd=sh, then you be given shell and you might able to recover this situation"
+ debugshell
+ [ "$DEBUGINITRD" ] || usleep 10000000
+ fi
+
exec switch_root /newroot $init ${1:+"$@"}
+ # FIXME: this code is never executed, as "exec" does not return!
+
echo "Error! initramfs should not reach this place."
echo "It probably means you've got old version of busybox, with broken"
echo "initramfs support. Trying to boot anyway, but won't promise anything."
@@ -1446,7 +1459,7 @@ add_linuxrc <<-'EOF'
EOF
if is_yes "$RUN_SULOGIN_ON_ERR"; then
add_linuxrc <<-'EOF'
- echo "debug shell disabled by /etc/sysconfig/system: RUN_SULOGIN_ON_ERR setting"
+ echo "debug shell disabled by RUN_SULOGIN_ON_ERR=yes from /etc/sysconfig/system during initrd generation time"
EOF
else
add_linuxrc <<-'EOF'
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/geninitrd.git/commitdiff/0273c2c4aa93f2c066f64adac9a494495d471e6a
More information about the pld-cvs-commit
mailing list