Re: mounting root from NFS via ROOTDEVNAME

From: Craig Rodrigues <rodrigc_at_crodrigues.org>
Date: Wed, 30 Jan 2013 13:43:51 -0800
On Wed, Jan 30, 2013 at 1:32 AM, Eggert, Lars <lars_at_netapp.com> wrote:

> Hi,
>
> On Jan 29, 2013, at 20:22, Craig Rodrigues <rodrigc_at_crodrigues.org> wrote:
>
>
> TFTP is not involved. The kernel gets booted by our custom loader (over
> HTTP) and the root FS is supposed to be mounted over NFS.
> > If through your setup you have already managed to load the kernel over
> > the network, then a lot of the hard work has been done.  Telling the
> kernel
> > where the root file system is located becomes the next tricky part.
>
> Right, that's the step I am struggeling with.
>
> > In src/sys/boot/common/boot.c which is part of the loader (not the
> kernel),
> > if you look in the getrootmount() function,
> > you will see that the loader will try to figure out where the root file
> > system
> > is by parsing /etc/fstab, and looking for the "/" mount.
> >
> > So, if your kernel is located in:
> >
> >       /usr/home/elars/dst/boot/kernel/kernel
> >
> > Then create a file /usr/home/elars/dst/etc/fstab file with something
> like:
> >
> > # Device                                         Mountpoint    FSType
> > Options  Dump Pass
> > 10.11.12.13:/usr/home/elars/dst/       /         nfs      ro        0
>  0
>
> Thanks, will try that!
>
> > Alternatively, if you don't want to create an /etc/fstab file, then
> > you could put something like this in your loader.conf file:
> >
> > vfs.root.mountfrom=nfs:10.11.12.13:/usr/home/elars/dst
>
> Will try that too, but not sure if this works with our custom loader.
>
>
>

Hi,

Thanks for the clarification.  I have a better idea of what you are trying
to do.
As you can imagine, not too many people have been playing with this type
of stuff.  A lot of this root mounting/NFS code was written about 14-15
years ago,
and not a lot of folks have been using it, but it is highly useful once you
get it to work.
Rick Macklem has been dusting off a lot of the cobwebs in the NFS code
thankfully.

Since your custom loader can load the kernel without using TFTP, I think
that this is a very good point.

Does your custom loader use any of the FreeBSD bootstrap or loader code?

What you need to do is, before the FreeBSD kernel boots, your
loader needs to export some environment variables.  This will trigger
the various behaviors in the FreeBSD mount code.

So as I suggested before, you should continue with:

(1)  Have /usr/home/elars/dst/etc/fstab with:
#  Options  Dump Pass
 10.11.12.13:/usr/home/elars/dst/       /         nfs      ro        0    0


(2)  From your loader, you need to export this environment variable, so
that the kernel can get it with getenv().  You need at least:

vfs.root.mountfrom=nfs:10.11.12.13:/usr/home/elars/dst



Now, there are some other environment variables you need to export from the
loader.  If you look in
src/sys/boot/i386/libi386/pxe.c, you will see that several environment
variables are set by
the FreeBSD loader (which is /boot/pxeboot on a FreeBSD system):

boot.netif.ip
boot.netif.netmask
boot.netif.gateway
boot.nfsroot.server
boot.nfsroot.path
dchp.host-name

These variables are then read by the FreeBSD kernel's NFS client root mount
code in src/sys/nfsclient/nfs_diskless.c.

If you can get those variables set properly in your loader, so that the
FreeBSD kernel can read them,
then I think this might work. :)
Basically, you need to give the kernel enough basic info about the IP
address, gateway, and netmask so it
can NFS mount the root file system.

Also, unless you really need them, I would recommend removing the BOOTP
options from your kernel config (unless you really feel you need them).
As others have pointed out, some of these options have not been tested for
a long time and might be buggy.  That is always
the risk when kernel options are not part of the GENERIC config.

Good luck!

-- 
Craig Rodrigues
rodrigc_at_crodrigues.org
Received on Wed Jan 30 2013 - 20:43:53 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:34 UTC