From owner-freebsd-current@FreeBSD.ORG Wed Jan 30 21:43:53 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 485FFAE6 for ; Wed, 30 Jan 2013 21:43:53 +0000 (UTC) (envelope-from crodr001@gmail.com) Received: from mail-la0-x232.google.com (la-in-x0232.1e100.net [IPv6:2a00:1450:4010:c03::232]) by mx1.freebsd.org (Postfix) with ESMTP id B2F908AA for ; Wed, 30 Jan 2013 21:43:52 +0000 (UTC) Received: by mail-la0-f50.google.com with SMTP id ec20so1448929lab.23 for ; Wed, 30 Jan 2013 13:43:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=fVUpoKaLGcB2YXy7bxO6GvWWmvvQadyPEtYYZg7RdrY=; b=qzumAFlg9SIHNUHtXaQm72Pv1+Cp2W3QvZyxK013lEBEjKb431ksSZf7Us6PmfDLBy E9JK0bW5DDAZF2jBnK+m1JC9q5LIj/uubnlJaVvT9nU19rdhrVNRXDBOD5TLYKZrl1At 7Gq1m8ybulMik0Os09EwRcGxJnEeBzcw8l3hSCcQQg5+tjnz6gFCs6/B9A3h5gAgQ+4z Ud5NUD65wU8j7qd7bjuIA50kYSmVXp/PaMWLsgVJH2Ftmsy2+3Xzq/XXiVKC1KS9tFcD 1xDkLhpzoDyJjNe5HzouBVwmMsvjKPoErcKfhC605fBVAOj6z8ZFtEd8nwPIt1OwQQ7I j15w== MIME-Version: 1.0 X-Received: by 10.112.98.105 with SMTP id eh9mr2490406lbb.131.1359582231626; Wed, 30 Jan 2013 13:43:51 -0800 (PST) Sender: crodr001@gmail.com Received: by 10.112.24.225 with HTTP; Wed, 30 Jan 2013 13:43:51 -0800 (PST) In-Reply-To: References: <19F92E0C-F004-4F16-A5FC-A10DF84BDCCF@netapp.com> Date: Wed, 30 Jan 2013 13:43:51 -0800 X-Google-Sender-Auth: rhHl5nCiZXPAXw6eLPL1qMf8JT0 Message-ID: Subject: Re: mounting root from NFS via ROOTDEVNAME From: Craig Rodrigues To: "Eggert, Lars" Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: "freebsd-current@freebsd.org" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Jan 2013 21:43:53 -0000 On Wed, Jan 30, 2013 at 1:32 AM, Eggert, Lars wrote: > Hi, > > On Jan 29, 2013, at 20:22, Craig Rodrigues 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