Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Nov 2022 20:37:58 -0700
From:      Warner Losh <imp@bsdimp.com>
To:        Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
Cc:        =?UTF-8?Q?Chlast=C3=A1k_Miroslav?= <mira@chlastak.cz>,  FreeBSD CURRENT <freebsd-current@freebsd.org>
Subject:   Re: loader.conf and rootdev option for memory disk
Message-ID:  <CANCZdfrYVXb1L_dud6p0=p623ey4uEVvGcm=rJNT1-XWrzbB5A@mail.gmail.com>
In-Reply-To: <CANCZdfpNtRnqoirja30q_7gotE=Z9w2MG-XhjFETwNQU=XzgLQ@mail.gmail.com>
References:  <2E58D34B-F8C5-4291-B019-9E24F56DC3DF@chlastak.cz> <CANCZdfqGhHXCJtUOctpoB-sAuxSdzJZERSBritTazp_uragZ=Q@mail.gmail.com> <F3702494-1433-4324-B972-52FBD84EFFD8@chlastak.cz> <20221120055845.366367f1d371ae4d6eb8d747@dec.sakura.ne.jp> <97A75B5E-6C38-4CFB-9978-7E254595D980@chlastak.cz> <20221120100046.b44741ca341c1593a72f594b@dec.sakura.ne.jp> <CANCZdfpNtRnqoirja30q_7gotE=Z9w2MG-XhjFETwNQU=XzgLQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000f7f4dc05eddeaa0f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Sat, Nov 19, 2022 at 8:32 PM Warner Losh <imp@bsdimp.com> wrote:

>
>
> On Sat, Nov 19, 2022 at 6:01 PM Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
> wrote:
>
>> But your previous post shows rootdev=3D there didn't work, and needed
>> setting vfs.root.mountfrom=3D.
>>
>> OTOH, rootdev=3D is reported to work in efi/boot/freebsd/loader.env (wit=
h
>> efi loader) on freebsd-users-jp ML (as it's Japanese ML, in Japanese)
>> this year.
>>
>> So /boot/defaults/loader.conf (/usr/src/stand/defaults/loader.conf)
>> should be fixed, and what should be set in loader.env should be
>> documented.
>>
>>  *Dedicated brand-new manpage or in boot.8 (or in loader.8 describing
>>   rootdev, or loader.conf.8 in contrast with itself).
>>
>
> Reading the code it's complicated.
>
> rootdev looks like it overrides the default root... unless
> vfs.root.mountfrom
> has already been set.
>

It's also a name in the 'boot loader' device namespace, not in the FreeBSD
device namespace, so it shouldn't be 'ufs:/dev/foo' but rather 'disk1p3:'
or similar. It's only when it's 'zfs:' that the boot loader device name
space
and the FreeBSD device name space overlap (also zfs: is special cased).

It's also a bit complicated because it's not used as 'currdev' either. It's
strictly a hint for where to mount FreeBSD's root front, but it's not used
to find boot scripts and config files. That's always done with 'currdev'
if no device is specified.

It's also a little more complex with OpenFirmware is involved, but
that's rare these days, so I'll not go into that.

Warner


>
>> On Sat, 19 Nov 2022 22:31:42 +0100
>> Chlast=C3=A1k Miroslav <mira@chlastak.cz> wrote:
>>
>> > Look at the file /boot/defaults/loader.conf:
>> >
>> > =E2=80=A6
>> > ###  Initial memory disk settings  ###########################
>> > #mdroot_load=3D"YES"              # The "mdroot" prefix is arbitrary.
>> > #mdroot_type=3D"md_image"         # Create md(4) disk at boot.
>> > #mdroot_name=3D"/boot/root.img"   # Path to a file containing the imag=
e.
>> > #rootdev=3D"ufs:/dev/md0"         # Set the root filesystem to md(4)
>> device.
>> > =E2=80=A6
>> >
>> > =E2=80=94
>> > Mira
>> >
>> > > On 19 Nov 2022, at 21:58, Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
>> wrote:
>> > >
>> > > IIUC, rootdev should be set in loader.env, if needed.
>> > > `man 5 loader.conf` has nothing about rootdev variable.
>> > >
>> > > (It's undocumented, IIRC.)
>> > >
>> > >
>> > > On Sat, 19 Nov 2022 19:57:47 +0100
>> > > Chlast=C3=A1k Miroslav <mira@chlastak.cz <mailto:mira@chlastak.cz>> =
wrote:
>> > >
>> > >> I have my device working for now - but the question is - Is the
>> documentation and example for =E2=80=9Crootdev=E2=80=9D right or not?
>> > >>
>> > >> =E2=80=94
>> > >> Mira
>> > >>
>> > >>> On 18 Nov 2022, at 21:13, Warner Losh <imp@bsdimp.com <mailto:
>> imp@bsdimp.com>> wrote:
>> > >>>
>> > >>>
>> > >>>
>> > >>> On Fri, Nov 18, 2022 at 12:57 PM Chlast=C3=A1k Miroslav <
>> mira@chlastak.cz <mailto:mira@chlastak.cz> <mailto:mira@chlastak.cz
>> <mailto:mira@chlastak.cz>>> wrote:
>> > >>> Hi all,
>> > >>>
>> > >>> In the /boot/defaults/loader.conf are these options for memory dis=
k
>> settings:
>> > >>>
>> > >>> #mdroot_load=3D"YES"              # The "mdroot" prefix is arbitra=
ry.
>> > >>> #mdroot_type=3D"md_image"         # Create md(4) disk at boot.
>> > >>> #mdroot_name=3D"/boot/root.img"   # Path to a file containing the
>> image.
>> > >>> #rootdev=3D"ufs:/dev/md0"         # Set the root filesystem to md(=
4)
>> device.
>> > >>>
>> > >>>
>> > >>> But - is this example for rootdev option still right? Because
>> =E2=80=9Cufs:/dev/md0=E2=80=9D works fine on freebsd 12.1, but on freebs=
d 12.3 this does
>> not work and generates error message:
>> > >>>
>> > >>> Can=E2=80=99t determine root device
>> > >>>
>> > >>>
>> > >>> When I use this option with value =E2=80=9C/dev/md0=E2=80=9D or =
=E2=80=9Cmd0=E2=80=9D (even with
>> this option commented out), so the machine boots correctly without any
>> error.
>> > >>>
>> > >>> I think you want vfs.root.mountfrom=3D instead of rootdev=3D here.
>> > >>>
>> > >>> Warner
>> > >>>
>> > >>> =E2=80=94
>> > >>> Mira
>> > >>
>> > >
>> > >
>> > > --
>> > > =E9=9D=92=E6=9C=A8 =E7=9F=A5=E6=98=8E  [Tomoaki AOKI]    <junchoon@d=
ec.sakura.ne.jp <mailto:
>> junchoon@dec.sakura.ne.jp>>
>> >
>>
>>
>> --
>> =E9=9D=92=E6=9C=A8 =E7=9F=A5=E6=98=8E  [Tomoaki AOKI]    <junchoon@dec.s=
akura.ne.jp>
>>
>>

--000000000000f7f4dc05eddeaa0f
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 Sat, Nov 19, 2022 at 8:32 PM Warne=
r Losh &lt;<a href=3D"mailto:imp@bsdimp.com">imp@bsdimp.com</a>&gt; wrote:<=
br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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 Sat, Nov 19, 2022 at 6:01 PM Tomoaki AOKI &lt;<a h=
ref=3D"mailto:junchoon@dec.sakura.ne.jp" target=3D"_blank">junchoon@dec.sak=
ura.ne.jp</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding=
-left:1ex">But your previous post shows rootdev=3D there didn&#39;t work, a=
nd needed<br>
setting vfs.root.mountfrom=3D.<br>
<br>
OTOH, rootdev=3D is reported to work in efi/boot/freebsd/loader.env (with<b=
r>
efi loader) on freebsd-users-jp ML (as it&#39;s Japanese ML, in Japanese)<b=
r>
this year.<br>
<br>
So /boot/defaults/loader.conf (/usr/src/stand/defaults/loader.conf)<br>
should be fixed, and what should be set in loader.env should be<br>
documented.<br>
<br>
=C2=A0*Dedicated brand-new manpage or in boot.8 (or in loader.8 describing<=
br>
=C2=A0 rootdev, or loader.conf.8 in contrast with itself).<br></blockquote>=
<div><br></div><div>Reading the code it&#39;s complicated.</div><div><br></=
div><div>rootdev looks like it overrides the default root... unless vfs.roo=
t.mountfrom</div><div>has already been set.<br></div></div></div></blockquo=
te><div><br></div><div>It&#39;s also a name in the &#39;boot loader&#39; de=
vice namespace, not in the FreeBSD</div><div>device namespace, so it should=
n&#39;t be &#39;ufs:/dev/foo&#39; but rather &#39;disk1p3:&#39;</div><div>o=
r similar. It&#39;s only when it&#39;s &#39;zfs:&#39; that the boot loader =
device name space</div><div>and the FreeBSD device name space overlap (also=
 zfs: is special cased).</div><div><br></div><div>It&#39;s also a bit compl=
icated because it&#39;s not used as &#39;currdev&#39; either. It&#39;s</div=
><div>strictly a hint for where to mount FreeBSD&#39;s root front, but it&#=
39;s not used</div><div>to find boot scripts and config files. That&#39;s a=
lways done with &#39;currdev&#39;</div><div>if no device is specified.</div=
><div><br></div><div>It&#39;s also a little more complex with OpenFirmware =
is involved, but</div><div>that&#39;s rare these days, so I&#39;ll not go i=
nto that.<br></div><div><br></div><div>Warner<br></div><div>=C2=A0</div><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef=
t:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div class=
=3D"gmail_quote"><div></div><blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1e=
x">
<br>
On Sat, 19 Nov 2022 22:31:42 +0100<br>
Chlast=C3=A1k Miroslav &lt;<a href=3D"mailto:mira@chlastak.cz" target=3D"_b=
lank">mira@chlastak.cz</a>&gt; wrote:<br>
<br>
&gt; Look at the file /boot/defaults/loader.conf:<br>
&gt; <br>
&gt; =E2=80=A6<br>
&gt; ###=C2=A0 Initial memory disk settings=C2=A0 #########################=
##<br>
&gt; #mdroot_load=3D&quot;YES&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 # The &quot;mdroot&quot; prefix is arbitrary.<br>
&gt; #mdroot_type=3D&quot;md_image&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0#=
 Create md(4) disk at boot.<br>
&gt; #mdroot_name=3D&quot;/boot/root.img&quot;=C2=A0 =C2=A0# Path to a file=
 containing the image.<br>
&gt; #rootdev=3D&quot;ufs:/dev/md0&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0#=
 Set the root filesystem to md(4) device.<br>
&gt; =E2=80=A6<br>
&gt; <br>
&gt; =E2=80=94<br>
&gt; Mira<br>
&gt; <br>
&gt; &gt; On 19 Nov 2022, at 21:58, Tomoaki AOKI &lt;<a href=3D"mailto:junc=
hoon@dec.sakura.ne.jp" target=3D"_blank">junchoon@dec.sakura.ne.jp</a>&gt; =
wrote:<br>
&gt; &gt; <br>
&gt; &gt; IIUC, rootdev should be set in loader.env, if needed.<br>
&gt; &gt; `man 5 loader.conf` has nothing about rootdev variable.<br>
&gt; &gt; <br>
&gt; &gt; (It&#39;s undocumented, IIRC.)<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; On Sat, 19 Nov 2022 19:57:47 +0100<br>
&gt; &gt; Chlast=C3=A1k Miroslav &lt;<a href=3D"mailto:mira@chlastak.cz" ta=
rget=3D"_blank">mira@chlastak.cz</a> &lt;mailto:<a href=3D"mailto:mira@chla=
stak.cz" target=3D"_blank">mira@chlastak.cz</a>&gt;&gt; wrote:<br>
&gt; &gt; <br>
&gt; &gt;&gt; I have my device working for now - but the question is - Is t=
he documentation and example for =E2=80=9Crootdev=E2=80=9D right or not?<br=
>
&gt; &gt;&gt; <br>
&gt; &gt;&gt; =E2=80=94<br>
&gt; &gt;&gt; Mira<br>
&gt; &gt;&gt; <br>
&gt; &gt;&gt;&gt; On 18 Nov 2022, at 21:13, Warner Losh &lt;<a href=3D"mail=
to:imp@bsdimp.com" target=3D"_blank">imp@bsdimp.com</a> &lt;mailto:<a href=
=3D"mailto:imp@bsdimp.com" target=3D"_blank">imp@bsdimp.com</a>&gt;&gt; wro=
te:<br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; On Fri, Nov 18, 2022 at 12:57 PM Chlast=C3=A1k Miroslav &=
lt;<a href=3D"mailto:mira@chlastak.cz" target=3D"_blank">mira@chlastak.cz</=
a> &lt;mailto:<a href=3D"mailto:mira@chlastak.cz" target=3D"_blank">mira@ch=
lastak.cz</a>&gt; &lt;mailto:<a href=3D"mailto:mira@chlastak.cz" target=3D"=
_blank">mira@chlastak.cz</a> &lt;mailto:<a href=3D"mailto:mira@chlastak.cz"=
 target=3D"_blank">mira@chlastak.cz</a>&gt;&gt;&gt; wrote:<br>
&gt; &gt;&gt;&gt; Hi all,<br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; In the /boot/defaults/loader.conf are these options for m=
emory disk settings:<br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; #mdroot_load=3D&quot;YES&quot;=C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 # The &quot;mdroot&quot; prefix is arbitrary.<br>
&gt; &gt;&gt;&gt; #mdroot_type=3D&quot;md_image&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0# Create md(4) disk at boot.<br>
&gt; &gt;&gt;&gt; #mdroot_name=3D&quot;/boot/root.img&quot;=C2=A0 =C2=A0# P=
ath to a file containing the image.<br>
&gt; &gt;&gt;&gt; #rootdev=3D&quot;ufs:/dev/md0&quot;=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0# Set the root filesystem to md(4) device.<br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; But - is this example for rootdev option still right? Bec=
ause =E2=80=9Cufs:/dev/md0=E2=80=9D works fine on freebsd 12.1, but on free=
bsd 12.3 this does not work and generates error message:<br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; Can=E2=80=99t determine root device<br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; When I use this option with value =E2=80=9C/dev/md0=E2=80=
=9D or =E2=80=9Cmd0=E2=80=9D (even with this option commented out), so the =
machine boots correctly without any error.<br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; I think you want vfs.root.mountfrom=3D instead of rootdev=
=3D here.<br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; Warner<br>
&gt; &gt;&gt;&gt; <br>
&gt; &gt;&gt;&gt; =E2=80=94<br>
&gt; &gt;&gt;&gt; Mira<br>
&gt; &gt;&gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; -- <br>
&gt; &gt; =E9=9D=92=E6=9C=A8 =E7=9F=A5=E6=98=8E=C2=A0 [Tomoaki AOKI]=C2=A0 =
=C2=A0 &lt;<a href=3D"mailto:junchoon@dec.sakura.ne.jp" target=3D"_blank">j=
unchoon@dec.sakura.ne.jp</a> &lt;mailto:<a href=3D"mailto:junchoon@dec.saku=
ra.ne.jp" target=3D"_blank">junchoon@dec.sakura.ne.jp</a>&gt;&gt;<br>
&gt; <br>
<br>
<br>
-- <br>
=E9=9D=92=E6=9C=A8 =E7=9F=A5=E6=98=8E=C2=A0 [Tomoaki AOKI]=C2=A0 =C2=A0 &lt=
;<a href=3D"mailto:junchoon@dec.sakura.ne.jp" target=3D"_blank">junchoon@de=
c.sakura.ne.jp</a>&gt;<br>
<br>
</blockquote></div></div>
</blockquote></div></div>

--000000000000f7f4dc05eddeaa0f--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfrYVXb1L_dud6p0=p623ey4uEVvGcm=rJNT1-XWrzbB5A>