Date: Wed, 30 Jan 2013 13:43:51 -0800 From: Craig Rodrigues <rodrigc@crodrigues.org> To: "Eggert, Lars" <lars@netapp.com> Cc: "freebsd-current@freebsd.org" <freebsd-current@freebsd.org> Subject: Re: mounting root from NFS via ROOTDEVNAME Message-ID: <CAG=rPVceQaKeprUyTXZyK13FSk2NY2sFT8LvG=wbQWsk08wwBQ@mail.gmail.com> In-Reply-To: <D4D47BCFFE5A004F95D707546AC0D7E91F69BF73@SACEXCMBX01-PRD.hq.netapp.com> References: <D4D47BCFFE5A004F95D707546AC0D7E91F671642@SACEXCMBX01-PRD.hq.netapp.com> <CAG=rPVergKVKUO=VySvM65WPJO_Od1tkWvx45tM_sEyO65mwUg@mail.gmail.com> <19F92E0C-F004-4F16-A5FC-A10DF84BDCCF@netapp.com> <D4D47BCFFE5A004F95D707546AC0D7E91F674CDE@SACEXCMBX01-PRD.hq.netapp.com> <CAG=rPVezTjcTp_AXsOMWYCSM1_xFJDvmUwdguHdZBABanGGrxw@mail.gmail.com> <D4D47BCFFE5A004F95D707546AC0D7E91F69BF73@SACEXCMBX01-PRD.hq.netapp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jan 30, 2013 at 1:32 AM, Eggert, Lars <lars@netapp.com> wrote: > Hi, > > On Jan 29, 2013, at 20:22, Craig Rodrigues <rodrigc@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@crodrigues.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG=rPVceQaKeprUyTXZyK13FSk2NY2sFT8LvG=wbQWsk08wwBQ>