home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] Just in case this happens to you

On Wed, 29 Jun 2011, Eric Brackenbury wrote:

> http://ubuntuforums.org/showthread.php?t=1555031
> This Saved the Day so it works, When    /sbin/init could not be found
> by the computer.

  since i'm intimately familiar with what seems to be happening here,
let me expand using my spectacularly impressive knowledge of the
kernel. :-)

  the important bit of kernel source can be found in the source file
init/main.c, down around line 754:

===== snip =====

        /*
         * We try each of these until one succeeds.
         *
         * The Bourne shell can be used instead of init if we are
         * trying to recover a really broken machine.
         */
        if (execute_command) {
                run_init_process(execute_command);
                printk(KERN_WARNING "Failed to execute %s.  Attempting "
                                        "defaults...\n", execute_command);
        }
        run_init_process("/sbin/init");
        run_init_process("/etc/init");
        run_init_process("/bin/init");
        run_init_process("/bin/sh");

        panic("No init found.  Try passing init= option to kernel. "
              "See Linux Documentation/init.txt for guidance.");

===== end snip =====

  that first test is checking whether you specified "init=<somepgm>"
on the kernel command line.  if you did, that code tries to execute
it.  if it fails, this isn't fatal -- as you can see, it's just a
warning and execution proceeds further.

  and if you *didn't* specify "init=", then you end up further down,
where you can see that the kernel code tries to execute four possible
executables in this order:

  * /sbin/init
  * /etc/init
  * /bin/init
  * /bin/sh

most distros will succeed with that first one.  if not, some of what
follows is just historical cruft (in ubuntu these days, /etc/init is a
*directory* so there's no way that's going to work).

  in any event, as you can see, you can override all of that
auto-checking by simply using, say, "init=/bin/sh" and jumping
straight to a shell.  of course, if you do this, you'll bypass
everything that init normally does for you, but it's good for
emergency work when even init has somehow gotten borked, as seems to
have happened here.  now *why* that happened, well, your guess is as
good as mine.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

references