Re: init (/rescue/sh) died

From: Warner Losh <imp_at_bsdimp.com>
Date: Mon, 22 Aug 2022 15:56:05 UTC
On Mon, Aug 22, 2022 at 9:17 AM Konstantin Belousov <kostikbel@gmail.com>
wrote:

> On Mon, Aug 22, 2022 at 02:56:47PM +0000, Bjoern A. Zeeb wrote:
> > Hi,
> >
> > I am trying to get some arm64 up and running a bit but cannot use
> > loader. I have an MD_ROOT embedded in the kernel with /rescue on it.
> > I set INIT_PATH=/rescue/sh .
> >
> > However that doesn't seem to work:
> >
> > start_init: trying /rescue/sh
> > init died (signal 0, exit 0)
> > panic: Going nowhere without my init!
> >
> > Anyone any ideas?
>
> Kernel does not set up the standard file descriptors for stdin/out/err
> for init.  When you try to directly exec /rescue/sh (or /bin/sh), it cannot
> perform any io.
>

Agreed. init does lots of magic, in addition to setting up stdin/out/err
(like
deal with process groups, etc). /bin/sh doesn't do any of that magic, so it
can't possibly work as init (PID 1).

Your best bet is to boot -s (RB_SINGLE in the kernel boot_single=yes in the
boot loader). You'd think you'd be able to symbolically link /etc/rc to
/rescue/sh,
but that will result in sh trying to execute /rescue/sh as a shell script
and no good
can come from it. I've had luck with "echo sh > $DESTDIR/etc/rc;
chmod +x $DESTDIR/etc/rc" in the past, but I haven't tried that trick in
ages...
The simple equivalent to a tmp file does work.

Warner