Re: mounting root from NFS via ROOTDEVNAME

From: Rick Macklem <rmacklem_at_uoguelph.ca>
Date: Wed, 30 Jan 2013 10:34:44 -0500 (EST)
Lars Eggert wrote:
> Hi,
> 
> On Jan 29, 2013, at 20:22, Craig Rodrigues <rodrigc_at_crodrigues.org>
> wrote:
> > What kind of architecture are you trying to do this on? Is this
> > i386/amd64 or something else?
> 
> amd64
> 
> >  I am not familiar with netboot compared to
> > PXE. Is TFTP involved at all with netboot?
> 
> 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.
> 
> > What does your dhcpd configuration file look like?
> 
> Completely standard, with the addition of a "root-path" option. (Which
> I would like to get rid of by setting ROOTDEVNAME in the kernel.)
> 
> > Also, are you using the FreeBSD loader, or something else? What
> > kinds of
> > customizations have you done on the loader?
> 
> Custom loader.
> 
> > 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.
> 
If you have "options BOOTP" and "options BOOTP_NFSROOT", the VFS_MOUNT()/nfs_mount()
call early in vfs_mountroot() calls bootpc_init(). This function and
related code is in sys/nfs/bootp_subr.c.

At a glance, the code in sys/nfs/bootp_subr.c tries very hard to get
"root-path" in several places, so it will take some fiddling to get it
to work without the dhcpd returning a root-path option. (I think Ian Lepore
has started to work on this.) I don't have any way of testing this until
at least April, so I can't really help.

It should be possible to modify bootp_subr.c, so that it uses ROOTDEVNAME
instead of trying to get "root-path" from the dhcp server when it is specified,
but the change will take some work.

If you want bootpc_init() to be called when "options BOOTP_NFSROOT" isn't
specified, that is a one line change in sys/fs/nfsclient/nfs_clvfsops.c.
(Just look for the bootpc_init() call, but I don't see that as being useful?

I think changing bootpc_init() and friends to avoid getting root-path when it
has already been specified (by ROOTDEVNAME and/or vfs.root.mountfrom) is the
best approach, but will require a significant patch to bootp_subr.c.

I can see two other approaches to doing this:
1 - Supply a root-path via the dhcpd, but override what it says later in
    the kernel boot, to use what is specified by ROOTDEVNAME or
    vfs.root.mountfrom. I haven't looked at what this would take, but
    I didn't see how it could be done with the current code,
    because the NFS client code expects a structure called nfsv3_diskless
    to be filled in by bootpc_init()
OR
2 - nfs_diskless(). The call to nfs_diskless() is done when "options NFS_ROOT"
    is specified, but "options BOOTP" + "options BOOTP_NFSROOT" is not.
    (Just look at the calls in sys/fs/nfs/nfs_clvfsops.c or sys/nfsclient/nfs_vfsops.c.)
    It fills the structure in from a bunch of environment variables. These
    are normally filled in by pxeboot, but you could modify your custom loader
    to fill them in, which would be this approach.

Once eithe nfs_diskless() or bootpc_init() has filled in nfsv3_diskless and
set nfs_diskless_valid, then the rest of the code uses what is in that structure,
so one of these 2 functions needs to be called, unless you do a major re-write of
the diskless NFS booting stuff.

Good luck with it, rick

> > 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.
> 
> Lars
> 
> >
> > If you can get this to work without introducing new kernel options,
> > that would be ideal, because the kernel options you are
> > enabling are triggering behaviors.
> >
> > --
> > Craig Rodrigues
> > rodrigc_at_crodrigues.org
> 
> _______________________________________________
> freebsd-current_at_freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to
> "freebsd-current-unsubscribe_at_freebsd.org"
Received on Wed Jan 30 2013 - 14:35:08 UTC

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