Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Aug 2022 15:51:03 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        "Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net>
Cc:        Konstantin Belousov <kostikbel@gmail.com>, FreeBSD Current <current@freebsd.org>
Subject:   Re: init (/rescue/sh) died
Message-ID:  <CANCZdfq06T7h5ws48v6h=V9b12SMES3A37VbgG-D77an9pXxdw@mail.gmail.com>
In-Reply-To: <n77oppp8-n960-po93-np43-q725553soq8q@yvfgf.mnoonqbm.arg>
References:  <pp3n1s2s-s5os-pp6-67sp-736soo193n6n@mnoonqbm.arg> <YwOd5CeXTZ9p7jRh@kib.kiev.ua> <CANCZdfrwX=60Vi_xo%2B=bkOZhgw2Q6Bui2L-u8jm5Dp0iqRmqhA@mail.gmail.com> <n77oppp8-n960-po93-np43-q725553soq8q@yvfgf.mnoonqbm.arg>

next in thread | previous in thread | raw e-mail | index | archive | help
--0000000000006390d905e6db72cb
Content-Type: text/plain; charset="UTF-8"

On Mon, Aug 22, 2022 at 12:29 PM Bjoern A. Zeeb <
bzeeb-lists@lists.zabbadoz.net> wrote:

> On Mon, 22 Aug 2022, Warner Losh wrote:
>
> Hi,
>
> > 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.
>
> /rescue/init was simply "hanging" on earlier boots which is why I
> had initially switche dto sh.
>
> Here's a few things I did overall:
> - disable GDB in kernel config (it gave 2 lines of jitterish on
>    initial kernel printf lines before Copyrights.
> - Added bootargs = FreeBSD:-vs to the chosen section in FDT
>    given I cannot have loader (no EFI); the guard trick is nice if you
>    know about it ;)
>

No EFI doesn't mean you can't have a loader :). What environment are you
booting in? Seems interesting...


> - Removed my previous env file I had added to the kernel to set
>    tunables.
> - linked /bin/sh to /rescue/sh
> - put a printf "hello world\n"; exit 1 in the top of /etc/rc just in
>    case -s wouldn't work
> - changed INIT_PATH=/rescue/init
>
> Got a sh and can run sysctl and dmesg and type echo * in /rescue :)
> Even reboot works :)
>
> Now that basic netbooting and user space work I can start adding SoC
> drivers bit by bit over the next weeks/months :)  That'll be a lot
> more unfun.
>
> Thanks you two!  Along with help from Andy earlier this made my day!
>

Glad I could help...

Warner

--0000000000006390d905e6db72cb
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Mon, Aug 22, 2022 at 12:29 PM Bjoe=
rn A. Zeeb &lt;<a href=3D"mailto:bzeeb-lists@lists.zabbadoz.net">bzeeb-list=
s@lists.zabbadoz.net</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204=
);padding-left:1ex">On Mon, 22 Aug 2022, Warner Losh wrote:<br>
<br>
Hi,<br>
<br>
&gt; On Mon, Aug 22, 2022 at 9:17 AM Konstantin Belousov &lt;<a href=3D"mai=
lto:kostikbel@gmail.com" target=3D"_blank">kostikbel@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;<br>
&gt;&gt; On Mon, Aug 22, 2022 at 02:56:47PM +0000, Bjoern A. Zeeb wrote:<br=
>
&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I am trying to get some arm64 up and running a bit but cannot =
use<br>
&gt;&gt;&gt; loader. I have an MD_ROOT embedded in the kernel with /rescue =
on it.<br>
&gt;&gt;&gt; I set INIT_PATH=3D/rescue/sh .<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; However that doesn&#39;t seem to work:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; start_init: trying /rescue/sh<br>
&gt;&gt;&gt; init died (signal 0, exit 0)<br>
&gt;&gt;&gt; panic: Going nowhere without my init!<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Anyone any ideas?<br>
&gt;&gt;<br>
&gt;&gt; Kernel does not set up the standard file descriptors for stdin/out=
/err<br>
&gt;&gt; for init.=C2=A0 When you try to directly exec /rescue/sh (or /bin/=
sh), it cannot<br>
&gt;&gt; perform any io.<br>
&gt;&gt;<br>
&gt;<br>
&gt; Agreed. init does lots of magic, in addition to setting up stdin/out/e=
rr<br>
&gt; (like<br>
&gt; deal with process groups, etc). /bin/sh doesn&#39;t do any of that mag=
ic, so it<br>
&gt; can&#39;t possibly work as init (PID 1).<br>
&gt;<br>
&gt; Your best bet is to boot -s (RB_SINGLE in the kernel boot_single=3Dyes=
 in the<br>
&gt; boot loader). You&#39;d think you&#39;d be able to symbolically link /=
etc/rc to<br>
&gt; /rescue/sh,<br>
&gt; but that will result in sh trying to execute /rescue/sh as a shell scr=
ipt<br>
&gt; and no good<br>
&gt; can come from it. I&#39;ve had luck with &quot;echo sh &gt; $DESTDIR/e=
tc/rc;<br>
&gt; chmod +x $DESTDIR/etc/rc&quot; in the past, but I haven&#39;t tried th=
at trick in<br>
&gt; ages...<br>
&gt; The simple equivalent to a tmp file does work.<br>
<br>
/rescue/init was simply &quot;hanging&quot; on earlier boots which is why I=
<br>
had initially switche dto sh.<br>
<br>
Here&#39;s a few things I did overall:<br>
- disable GDB in kernel config (it gave 2 lines of jitterish on<br>
=C2=A0 =C2=A0initial kernel printf lines before Copyrights.<br>
- Added bootargs =3D FreeBSD:-vs to the chosen section in FDT<br>
=C2=A0 =C2=A0given I cannot have loader (no EFI); the guard trick is nice i=
f you<br>
=C2=A0 =C2=A0know about it ;)<br></blockquote><div><br></div><div>No EFI do=
esn&#39;t mean you can&#39;t have a loader :). What environment are you</di=
v><div>booting in? Seems interesting...</div><div>=C2=A0</div><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px soli=
d rgb(204,204,204);padding-left:1ex">
- Removed my previous env file I had added to the kernel to set<br>
=C2=A0 =C2=A0tunables.<br>
- linked /bin/sh to /rescue/sh<br>
- put a printf &quot;hello world\n&quot;; exit 1 in the top of /etc/rc just=
 in<br>
=C2=A0 =C2=A0case -s wouldn&#39;t work<br>
- changed INIT_PATH=3D/rescue/init<br>
<br>
Got a sh and can run sysctl and dmesg and type echo * in /rescue :)<br>
Even reboot works :)<br>
<br>
Now that basic netbooting and user space work I can start adding SoC<br>
drivers bit by bit over the next weeks/months :)=C2=A0 That&#39;ll be a lot=
<br>
more unfun.<br>
<br>
Thanks you two!=C2=A0 Along with help from Andy earlier this made my day!<b=
r></blockquote><div><br></div><div>Glad I could help...</div><div><br></div=
><div>Warner=C2=A0</div></div></div>

--0000000000006390d905e6db72cb--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfq06T7h5ws48v6h=V9b12SMES3A37VbgG-D77an9pXxdw>