]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
sleep before switch_root is about to fail
authorElan Ruusamäe <glen@delfi.ee>
Tue, 24 Dec 2013 00:23:20 +0000 (02:23 +0200)
committerElan Ruusamäe <glen@delfi.ee>
Tue, 24 Dec 2013 00:24:57 +0000 (02:24 +0200)
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

index ff0d958535eec7a67ec7106c228f175e00a9d1b3..fdca56b700997c5ea8a8bff80f848dd3eb71d86d 100755 (executable)
--- 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'
This page took 0.068396 seconds and 4 git commands to generate.