Re: mounting root from NFS via ROOTDEVNAME
On Sun, 2013-06-02 at 19:57 -0400, Rick Macklem wrote: Ian Lepore wrote: On Sat, 2013-06-01 at 20:28 -0400, Rick Macklem wrote: Lars Eggert wrote: Hi, to conclude this thread, the patch below allows one to specify an nfs rootfs via the ROOTDEVNAME kernel option, which will be mounted when BOOTP does not return a root-path option. Lars My only concern with this (mainly because I don't understand the rules applied to boot alternatives well enough) is that a few arm configs have both BOOTP, BOOTP_NFSROOT and ROOTDEVNAME specified, where ROOTDEVNAME is set to ufs: I don't think this patch will break them, since I think they'll use NFS and ignore the ROOTDEVNAME, but I'm not completely sure. Does someone else know how HL201 boots, for example? Lars, if you have a src commit, you can consider this reviewed by me. If not, maybe Craig can review it and then I'll commit it. Thanks for doing this, rick diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index 2c57a91..972fb12 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -45,6 +45,7 @@ __FBSDID($FreeBSD$); #include opt_bootp.h #include opt_nfs.h +#include opt_rootdevname.h #include sys/param.h #include sys/systm.h @@ -870,8 +871,20 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) rtimo = time_second + BOOTP_SETTLE_DELAY; printf( (got root path)); - } else + } else { printf( (no root path)); +#ifdef ROOTDEVNAME + /* + * If we'll mount rootfs from + * ROOTDEVNAME, we can accept + * offers without root paths. + */ + gotrootpath = 1; + rtimo = time_second + + BOOTP_SETTLE_DELAY; + printf( (ROOTDEVNAME)); +#endif + } printf(\n); } } /* while secs */ @@ -1440,6 +1453,16 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, p = bootpc_tag(gctx-tag, ifctx-reply, ifctx-replylen, TAG_ROOT); +#ifdef ROOTDEVNAME + /* + * If there was no root path in BOOTP, use the one in ROOTDEVNAME. + */ + if (p == NULL) { + p = strdup(ROOTDEVNAME, M_TEMP); + if (strcmp(strsep(p, :), nfs) != 0) + panic(ROOTDEVNAME is not an NFS mount point); + } +#endif if (p != NULL) { if (gctx-setrootfs != NULL) { printf(rootfs %s (ignored) , p); I've seen several requests over the past year for an nfs ROOTDEVNAME along with BOOTP to work properly from ARM developers (myself included), so I don't think we should worry about breaking existing config that happens to be checked in but a) hasn't been tested by anyone for ages, and b) doesn't work anyway (ROOTDEVNAME just gets ignored). -- Ian Cool. Thanks. Would you like to review and/or test the above? I'll be happy to commit it if Lars doesn't have a src commit bit. (I've seen his posts, but can't remember if he is a committer?) rick Well, I started out just testing Lars' patch (it works) but that inspired me to pick up the work I toyed with months ago in this area, to try to get BOOTP_NFSROOT to respect other root-path options such as setting vfs.root.mountfrom in the environment and using the RB_DFLTROOT boot option. The attached patch does those things, as follows: This maintains the historical BOOTP_NFSROOT behavior of panicking on a failure to mount the root path provided by the server, unless you've provided an alternative via ROOTDEVNAME or vfs.root.mountfrom. I was afraid to change this behavior because it amounts to a bit of a retry loop that could eventually recover from a transient network or server problem. The user can now override the root path from loader(8) even if the kernel is compiled with BOOTP_NFSROOT. If vfs.root.mountfrom is set in the environment it is used unconditionally -- it always overrides the BOOTP info. If it begins with [old]nfs: then the BOOTP code uses it instead of the server-provided info. If it specifies some other filesystem then the bootp code will not panic and the code in vfs_mountroot.c will invoke the right filesystem to do the mount. If the kernel is compiled with the ROOTDEVNAME option, then that name is used by the BOOTP code if either * The server doesn't provide a pathname. * The boothowto flags include RB_DFLTROOT. The latter allows the user to specify an alternate path in ROOTDEVNAME such as ufs:/dev/da0s1a and boot from that path by setting boot_dftlroot=1 in loader(8) or using the '-r' option in boot(8). The one thing not provided here is automatic failover from a server-provided path to a compiled-in one without the user manually requesting that. The code just isn't currently structured in a way that makes that possible with a lot of rewrite. I think the ability to set vfs.root.mountfrom and to use ROOTDEVNAME automatically when the server doesn't
Re: mounting root from NFS via ROOTDEVNAME
On Thu, Jun 6, 2013 at 9:54 AM, Ian Lepore i...@freebsd.org wrote: Well, I started out just testing Lars' patch (it works) but that inspired me to pick up the work I toyed with months ago in this area, to try to get BOOTP_NFSROOT to respect other root-path options such as setting vfs.root.mountfrom in the environment and using the RB_DFLTROOT boot option. The attached patch does those things, as follows: Your patch is better than the existing code. Your patch makes the code more readable. In my earlier response on this thread, I threw out the idea of axing ROOTDEVNAME from the kernel config options. I had a feeling that there would be opposition to it, so I'm OK with it staying. What I don't like to see is a lot of code behind conditional preprocessor logic of #ifdef ROOTDEVNAME. This often leads to bitrot if ROOTDEVNAME is not part of the GENERIC kernel config. However, with your patch, the amount of code inside #ifdef ROOTDEVNAME blocks is very minimal, so I can live with that. With your patch, we can trigger all the behavior by setting vfs.mountfrom in loader.conf with an nfs: prefix, so that is good, in terms of testing the feature with GENERIC kernels. I would say, if Lars Eggert has time to provide feedback and is OK with your patch, then go with your patch and commit it. The only minor feedback I would give is that in this comment: +/* + * Choose a root filesystem. If a value is forced in the environment + * and it contains nfs:, use it unconditionally. Otherwise, use + * ROOTDEVNAME if it contains nfs: and either the server didn't + * provide a name or the boot options say to force ROOTDEVNAME. + */ + If you could take the sentence starting with Otherwise, use, and maybe split it up into two sentences, that would make the comment a little bit more readable. Thanks. -- Craig ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Mon, 3 Jun 2013 00:06:44 -0700 Craig Rodrigues rodr...@crodrigues.org wrote: On Tue, May 28, 2013 at 8:13 AM, Eggert, Lars l...@netapp.com wrote: Hi, to conclude this thread, the patch below allows one to specify an nfs rootfs via the ROOTDEVNAME kernel option, which will be mounted when BOOTP does not return a root-path option. Lars diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index 2c57a91..972fb12 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -45,6 +45,7 @@ __FBSDID($FreeBSD$); #include opt_bootp.h #include opt_nfs.h +#include opt_rootdevname.h #include sys/param.h #include sys/systm.h @@ -870,8 +871,20 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) rtimo = time_second + BOOTP_SETTLE_DELAY; printf( (got root path)); - } else + } else { printf( (no root path)); +#ifdef ROOTDEVNAME + /* +* If we'll mount rootfs from +* ROOTDEVNAME, we can accept +* offers without root paths. +*/ + gotrootpath = 1; + rtimo = time_second + + BOOTP_SETTLE_DELAY; + printf( (ROOTDEVNAME)); +#endif + } printf(\n); } } /* while secs */ @@ -1440,6 +1453,16 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, p = bootpc_tag(gctx-tag, ifctx-reply, ifctx-replylen, TAG_ROOT); +#ifdef ROOTDEVNAME + /* +* If there was no root path in BOOTP, use the one in ROOTDEVNAME. +*/ + if (p == NULL) { + p = strdup(ROOTDEVNAME, M_TEMP); + if (strcmp(strsep(p, :), nfs) != 0) + panic(ROOTDEVNAME is not an NFS mount point); + } +#endif if (p != NULL) { if (gctx-setrootfs != NULL) { printf(rootfs %s (ignored) , p); Sorry for not responding, I've been busy for the past few days. Thank you for persisting with this, and trying to clean this up. This is relatively old code that hasn't been touched in about 15 years, so not that many people have worked on it. I don't like things like ROOTDEVNAME which need to be specified in the kernel config and are not part of the GENERIC kernel. This usually ends up where code which is behind #ifdef ROOTDEVNAME will bitrot because not everyone uses it. I would like to see the ROOTDEVNAME kernel option go away, in favor of a variable that can be specified in loader.conf. Please don't do that. We still have some amount of systems for which we can't get boot device name and we can't modify boot process, very often situation is a embedded system with U-Boot on board and no sources published anywhere for it. So if we want to be able to continue work with such systems - we must have, at least similar way to specify rootdev. Thanks! If I search the code via Opengrok, I with this: http://bxr.su/s?n=25start=25sort=relevancyq=ROOTDEVNAMEproject=FreeBSD there already seems to be a variable rootdev that is checked in a bunch of places in the loader, so it would be nice if we could use that. My personal preference would be to delete ROOTDEVNAME from all the kernel configs and deprecate the kernel option, and instead use a tunable variable which could be set in loader.conf. This may not be practical. Do you think it would be doable if we can have something like this in the kernel code: const char *rootdevname = #ifdef ROOTDEVNAME rootdevname = ROOTDEVNAME; #else rootdevname = NULL #endif if (rootdevname == NULL) { rootdevname = getenv(rootdev); } or something like that? -- Craig ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org -- Aleksandr Rybalko r...@ddteam.net ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Mon, 2013-06-03 at 00:06 -0700, Craig Rodrigues wrote: On Tue, May 28, 2013 at 8:13 AM, Eggert, Lars l...@netapp.com wrote: Hi, to conclude this thread, the patch below allows one to specify an nfs rootfs via the ROOTDEVNAME kernel option, which will be mounted when BOOTP does not return a root-path option. Lars diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index 2c57a91..972fb12 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -45,6 +45,7 @@ __FBSDID($FreeBSD$); #include opt_bootp.h #include opt_nfs.h +#include opt_rootdevname.h #include sys/param.h #include sys/systm.h @@ -870,8 +871,20 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) rtimo = time_second + BOOTP_SETTLE_DELAY; printf( (got root path)); - } else + } else { printf( (no root path)); +#ifdef ROOTDEVNAME + /* +* If we'll mount rootfs from +* ROOTDEVNAME, we can accept +* offers without root paths. +*/ + gotrootpath = 1; + rtimo = time_second + + BOOTP_SETTLE_DELAY; + printf( (ROOTDEVNAME)); +#endif + } printf(\n); } } /* while secs */ @@ -1440,6 +1453,16 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, p = bootpc_tag(gctx-tag, ifctx-reply, ifctx-replylen, TAG_ROOT); +#ifdef ROOTDEVNAME + /* +* If there was no root path in BOOTP, use the one in ROOTDEVNAME. +*/ + if (p == NULL) { + p = strdup(ROOTDEVNAME, M_TEMP); + if (strcmp(strsep(p, :), nfs) != 0) + panic(ROOTDEVNAME is not an NFS mount point); + } +#endif if (p != NULL) { if (gctx-setrootfs != NULL) { printf(rootfs %s (ignored) , p); Sorry for not responding, I've been busy for the past few days. Thank you for persisting with this, and trying to clean this up. This is relatively old code that hasn't been touched in about 15 years, so not that many people have worked on it. I don't like things like ROOTDEVNAME which need to be specified in the kernel config and are not part of the GENERIC kernel. This usually ends up where code which is behind #ifdef ROOTDEVNAME will bitrot because not everyone uses it. I would like to see the ROOTDEVNAME kernel option go away, in favor of a variable that can be specified in loader.conf. If I search the code via Opengrok, I with this: http://bxr.su/s?n=25start=25sort=relevancyq=ROOTDEVNAMEproject=FreeBSD there already seems to be a variable rootdev that is checked in a bunch of places in the loader, so it would be nice if we could use that. My personal preference would be to delete ROOTDEVNAME from all the kernel configs and deprecate the kernel option, and instead use a tunable variable which could be set in loader.conf. This may not be practical. Do you think it would be doable if we can have something like this in the kernel code: const char *rootdevname = #ifdef ROOTDEVNAME rootdevname = ROOTDEVNAME; #else rootdevname = NULL #endif if (rootdevname == NULL) { rootdevname = getenv(rootdev); } or something like that? I'm strongly opposed to removing the ROOTDEVNAME config option, for the simple reason that loader(8) is optional so there has to be a way to set certain basic runtime options at compile time, and ROOTDEVNAME is one of them. There is already a loader tunable for the root dev, vfs.root.mountfrom. Also, there is already a mechanism similar to your proposal above (but a bit more complex) in kern/vfs_mountroot.c. It sets up a list of potential roots based on the flags passed in from the boot(8) stage; ROOTDEVNAME will be near the beginning of the list of the RB_DFLTROOT option (-r at the boot: prompt) is used, and near the end of the list if it isn't. I vaguely remember that this mechanism doesn't work for nfs mounts, but I forget why (hopefully I'll rediscover it as I test Lars' patch this morning). -- Ian ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Hi, On Jun 3, 2013, at 1:57, Rick Macklem rmack...@uoguelph.ca wrote: Cool. Thanks. Would you like to review and/or test the above? it'd be great if folks would test this a bit. It certainly works for me, but I can't say that I have done a very thorough testing. I'll be happy to commit it if Lars doesn't have a src commit bit. (I've seen his posts, but can't remember if he is a committer?) I'm not a committer. Lars ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Tue, May 28, 2013 at 8:13 AM, Eggert, Lars l...@netapp.com wrote: Hi, to conclude this thread, the patch below allows one to specify an nfs rootfs via the ROOTDEVNAME kernel option, which will be mounted when BOOTP does not return a root-path option. Lars diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index 2c57a91..972fb12 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -45,6 +45,7 @@ __FBSDID($FreeBSD$); #include opt_bootp.h #include opt_nfs.h +#include opt_rootdevname.h #include sys/param.h #include sys/systm.h @@ -870,8 +871,20 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) rtimo = time_second + BOOTP_SETTLE_DELAY; printf( (got root path)); - } else + } else { printf( (no root path)); +#ifdef ROOTDEVNAME + /* +* If we'll mount rootfs from +* ROOTDEVNAME, we can accept +* offers without root paths. +*/ + gotrootpath = 1; + rtimo = time_second + + BOOTP_SETTLE_DELAY; + printf( (ROOTDEVNAME)); +#endif + } printf(\n); } } /* while secs */ @@ -1440,6 +1453,16 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, p = bootpc_tag(gctx-tag, ifctx-reply, ifctx-replylen, TAG_ROOT); +#ifdef ROOTDEVNAME + /* +* If there was no root path in BOOTP, use the one in ROOTDEVNAME. +*/ + if (p == NULL) { + p = strdup(ROOTDEVNAME, M_TEMP); + if (strcmp(strsep(p, :), nfs) != 0) + panic(ROOTDEVNAME is not an NFS mount point); + } +#endif if (p != NULL) { if (gctx-setrootfs != NULL) { printf(rootfs %s (ignored) , p); Sorry for not responding, I've been busy for the past few days. Thank you for persisting with this, and trying to clean this up. This is relatively old code that hasn't been touched in about 15 years, so not that many people have worked on it. I don't like things like ROOTDEVNAME which need to be specified in the kernel config and are not part of the GENERIC kernel. This usually ends up where code which is behind #ifdef ROOTDEVNAME will bitrot because not everyone uses it. I would like to see the ROOTDEVNAME kernel option go away, in favor of a variable that can be specified in loader.conf. If I search the code via Opengrok, I with this: http://bxr.su/s?n=25start=25sort=relevancyq=ROOTDEVNAMEproject=FreeBSD there already seems to be a variable rootdev that is checked in a bunch of places in the loader, so it would be nice if we could use that. My personal preference would be to delete ROOTDEVNAME from all the kernel configs and deprecate the kernel option, and instead use a tunable variable which could be set in loader.conf. This may not be practical. Do you think it would be doable if we can have something like this in the kernel code: const char *rootdevname = #ifdef ROOTDEVNAME rootdevname = ROOTDEVNAME; #else rootdevname = NULL #endif if (rootdevname == NULL) { rootdevname = getenv(rootdev); } or something like that? -- Craig ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Sat, 2013-06-01 at 20:28 -0400, Rick Macklem wrote: Lars Eggert wrote: Hi, to conclude this thread, the patch below allows one to specify an nfs rootfs via the ROOTDEVNAME kernel option, which will be mounted when BOOTP does not return a root-path option. Lars My only concern with this (mainly because I don't understand the rules applied to boot alternatives well enough) is that a few arm configs have both BOOTP, BOOTP_NFSROOT and ROOTDEVNAME specified, where ROOTDEVNAME is set to ufs: I don't think this patch will break them, since I think they'll use NFS and ignore the ROOTDEVNAME, but I'm not completely sure. Does someone else know how HL201 boots, for example? Lars, if you have a src commit, you can consider this reviewed by me. If not, maybe Craig can review it and then I'll commit it. Thanks for doing this, rick diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index 2c57a91..972fb12 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -45,6 +45,7 @@ __FBSDID($FreeBSD$); #include opt_bootp.h #include opt_nfs.h +#include opt_rootdevname.h #include sys/param.h #include sys/systm.h @@ -870,8 +871,20 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) rtimo = time_second + BOOTP_SETTLE_DELAY; printf( (got root path)); - } else + } else { printf( (no root path)); +#ifdef ROOTDEVNAME + /* + * If we'll mount rootfs from + * ROOTDEVNAME, we can accept + * offers without root paths. + */ + gotrootpath = 1; + rtimo = time_second + + BOOTP_SETTLE_DELAY; + printf( (ROOTDEVNAME)); +#endif + } printf(\n); } } /* while secs */ @@ -1440,6 +1453,16 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, p = bootpc_tag(gctx-tag, ifctx-reply, ifctx-replylen, TAG_ROOT); +#ifdef ROOTDEVNAME + /* + * If there was no root path in BOOTP, use the one in ROOTDEVNAME. + */ + if (p == NULL) { + p = strdup(ROOTDEVNAME, M_TEMP); + if (strcmp(strsep(p, :), nfs) != 0) + panic(ROOTDEVNAME is not an NFS mount point); + } +#endif if (p != NULL) { if (gctx-setrootfs != NULL) { printf(rootfs %s (ignored) , p); I've seen several requests over the past year for an nfs ROOTDEVNAME along with BOOTP to work properly from ARM developers (myself included), so I don't think we should worry about breaking existing config that happens to be checked in but a) hasn't been tested by anyone for ages, and b) doesn't work anyway (ROOTDEVNAME just gets ignored). -- Ian ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Ian Lepore wrote: On Sat, 2013-06-01 at 20:28 -0400, Rick Macklem wrote: Lars Eggert wrote: Hi, to conclude this thread, the patch below allows one to specify an nfs rootfs via the ROOTDEVNAME kernel option, which will be mounted when BOOTP does not return a root-path option. Lars My only concern with this (mainly because I don't understand the rules applied to boot alternatives well enough) is that a few arm configs have both BOOTP, BOOTP_NFSROOT and ROOTDEVNAME specified, where ROOTDEVNAME is set to ufs: I don't think this patch will break them, since I think they'll use NFS and ignore the ROOTDEVNAME, but I'm not completely sure. Does someone else know how HL201 boots, for example? Lars, if you have a src commit, you can consider this reviewed by me. If not, maybe Craig can review it and then I'll commit it. Thanks for doing this, rick diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index 2c57a91..972fb12 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -45,6 +45,7 @@ __FBSDID($FreeBSD$); #include opt_bootp.h #include opt_nfs.h +#include opt_rootdevname.h #include sys/param.h #include sys/systm.h @@ -870,8 +871,20 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) rtimo = time_second + BOOTP_SETTLE_DELAY; printf( (got root path)); - } else + } else { printf( (no root path)); +#ifdef ROOTDEVNAME + /* + * If we'll mount rootfs from + * ROOTDEVNAME, we can accept + * offers without root paths. + */ + gotrootpath = 1; + rtimo = time_second + + BOOTP_SETTLE_DELAY; + printf( (ROOTDEVNAME)); +#endif + } printf(\n); } } /* while secs */ @@ -1440,6 +1453,16 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, p = bootpc_tag(gctx-tag, ifctx-reply, ifctx-replylen, TAG_ROOT); +#ifdef ROOTDEVNAME + /* + * If there was no root path in BOOTP, use the one in ROOTDEVNAME. + */ + if (p == NULL) { + p = strdup(ROOTDEVNAME, M_TEMP); + if (strcmp(strsep(p, :), nfs) != 0) + panic(ROOTDEVNAME is not an NFS mount point); + } +#endif if (p != NULL) { if (gctx-setrootfs != NULL) { printf(rootfs %s (ignored) , p); I've seen several requests over the past year for an nfs ROOTDEVNAME along with BOOTP to work properly from ARM developers (myself included), so I don't think we should worry about breaking existing config that happens to be checked in but a) hasn't been tested by anyone for ages, and b) doesn't work anyway (ROOTDEVNAME just gets ignored). -- Ian Cool. Thanks. Would you like to review and/or test the above? I'll be happy to commit it if Lars doesn't have a src commit bit. (I've seen his posts, but can't remember if he is a committer?) rick ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Lars Eggert wrote: Hi, to conclude this thread, the patch below allows one to specify an nfs rootfs via the ROOTDEVNAME kernel option, which will be mounted when BOOTP does not return a root-path option. Lars My only concern with this (mainly because I don't understand the rules applied to boot alternatives well enough) is that a few arm configs have both BOOTP, BOOTP_NFSROOT and ROOTDEVNAME specified, where ROOTDEVNAME is set to ufs: I don't think this patch will break them, since I think they'll use NFS and ignore the ROOTDEVNAME, but I'm not completely sure. Does someone else know how HL201 boots, for example? Lars, if you have a src commit, you can consider this reviewed by me. If not, maybe Craig can review it and then I'll commit it. Thanks for doing this, rick diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index 2c57a91..972fb12 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -45,6 +45,7 @@ __FBSDID($FreeBSD$); #include opt_bootp.h #include opt_nfs.h +#include opt_rootdevname.h #include sys/param.h #include sys/systm.h @@ -870,8 +871,20 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) rtimo = time_second + BOOTP_SETTLE_DELAY; printf( (got root path)); - } else + } else { printf( (no root path)); +#ifdef ROOTDEVNAME + /* + * If we'll mount rootfs from + * ROOTDEVNAME, we can accept + * offers without root paths. + */ + gotrootpath = 1; + rtimo = time_second + + BOOTP_SETTLE_DELAY; + printf( (ROOTDEVNAME)); +#endif + } printf(\n); } } /* while secs */ @@ -1440,6 +1453,16 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, p = bootpc_tag(gctx-tag, ifctx-reply, ifctx-replylen, TAG_ROOT); +#ifdef ROOTDEVNAME + /* + * If there was no root path in BOOTP, use the one in ROOTDEVNAME. + */ + if (p == NULL) { + p = strdup(ROOTDEVNAME, M_TEMP); + if (strcmp(strsep(p, :), nfs) != 0) + panic(ROOTDEVNAME is not an NFS mount point); + } +#endif if (p != NULL) { if (gctx-setrootfs != NULL) { printf(rootfs %s (ignored) , p); ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Hi, to conclude this thread, the patch below allows one to specify an nfs rootfs via the ROOTDEVNAME kernel option, which will be mounted when BOOTP does not return a root-path option. Lars diff --git a/sys/nfs/bootp_subr.c b/sys/nfs/bootp_subr.c index 2c57a91..972fb12 100644 --- a/sys/nfs/bootp_subr.c +++ b/sys/nfs/bootp_subr.c @@ -45,6 +45,7 @@ __FBSDID($FreeBSD$); #include opt_bootp.h #include opt_nfs.h +#include opt_rootdevname.h #include sys/param.h #include sys/systm.h @@ -870,8 +871,20 @@ bootpc_call(struct bootpc_globalcontext *gctx, struct thread *td) rtimo = time_second + BOOTP_SETTLE_DELAY; printf( (got root path)); - } else + } else { printf( (no root path)); +#ifdef ROOTDEVNAME + /* +* If we'll mount rootfs from +* ROOTDEVNAME, we can accept +* offers without root paths. +*/ + gotrootpath = 1; + rtimo = time_second + + BOOTP_SETTLE_DELAY; + printf( (ROOTDEVNAME)); +#endif + } printf(\n); } } /* while secs */ @@ -1440,6 +1453,16 @@ bootpc_decode_reply(struct nfsv3_diskless *nd, struct bootpc_ifcontext *ifctx, p = bootpc_tag(gctx-tag, ifctx-reply, ifctx-replylen, TAG_ROOT); +#ifdef ROOTDEVNAME + /* +* If there was no root path in BOOTP, use the one in ROOTDEVNAME. +*/ + if (p == NULL) { + p = strdup(ROOTDEVNAME, M_TEMP); + if (strcmp(strsep(p, :), nfs) != 0) + panic(ROOTDEVNAME is not an NFS mount point); + } +#endif if (p != NULL) { if (gctx-setrootfs != NULL) { printf(rootfs %s (ignored) , p); ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Hi, On Jan 30, 2013, at 22:43, Craig Rodrigues rodr...@crodrigues.org wrote: 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. the loader can export some environment variables (this is how I get the serial console working.) 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 ro00 Done. (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 Done. Now, there are some other environment variables you need to export from the loader. boot.netif.ip boot.netif.netmask boot.netif.gateway boot.nfsroot.server boot.nfsroot.path Done. I also ripped out all the BOOTP* options from the kernel. However, this still fails: Trying to mount root from nfs:10.11.12.13:/usr/home/elars/dst []... mountroot: waiting for device 10.11.12.13:/usr/home/elars/dst ... Mounting from nfs:10.11.12.13:/usr/home/elars/dst failed with error 19. Loader variables: vfs.root.mountfrom=nfs:10.11.12.13:/usr/home/elars/dst Manual root filesystem specification: fstype:device [options] Mount device using filesystem fstype and with the specified (optional) option list. eg. ufs:/dev/da0s1a zfs:tank cd9660:/dev/acd0 ro (which is equivalent to: mount -t cd9660 -o ro /dev/acd0 /) ? List valid disk boot devices . Yield 1 second (for background tasks) empty lineAbort manual input mountroot I did a tcpdump and no traffic shows up on the correct interface (em4). I guess I need to set yet another loader environment variable to indicate which interface I'd like to use. Looking at the source, I only see boot.netif.name, but setting that to em4 doesn't help either. Any further ideas? Thanks, Lars ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Done. I also ripped out all the BOOTP* options from the kernel. However, this still fails: Trying to mount root from nfs:10.11.12.13:/usr/home/elars/dst []... mountroot: waiting for device 10.11.12.13:/usr/home/elars/dst ... Mounting from nfs:10.11.12.13:/usr/home/elars/dst failed with error 19. Loader variables: vfs.root.mountfrom=nfs:10.11.12.13:/usr/home/elars/dst Manual root filesystem specification: fstype:device [options] Mount device using filesystem fstype and with the specified (optional) option list. eg. ufs:/dev/da0s1a zfs:tank cd9660:/dev/acd0 ro (which is equivalent to: mount -t cd9660 -o ro /dev/acd0 /) ? List valid disk boot devices . Yield 1 second (for background tasks) empty lineAbort manual input mountroot I did a tcpdump and no traffic shows up on the correct interface (em4). I guess I need to set yet another loader environment variable to indicate which interface I'd like to use. Looking at the source, I only see boot.netif.name, but setting that to em4 doesn't help either. Any further ideas? Thanks, Lars Just a shot in the dark, did you actually tell it to do the root mount ro, or try with the nfs share as rw? Best regards Andreas ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On 31.01.2013 12:27, Eggert, Lars wrote: Hi, On Jan 30, 2013, at 22:43, Craig Rodrigues rodr...@crodrigues.org wrote: 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. the loader can export some environment variables (this is how I get the serial console working.) 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 ro00 Done. (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 Done. Now, there are some other environment variables you need to export from the loader. boot.netif.ip boot.netif.netmask boot.netif.gateway boot.nfsroot.server boot.nfsroot.path Done. I also ripped out all the BOOTP* options from the kernel. However, this still fails: Trying to mount root from nfs:10.11.12.13:/usr/home/elars/dst []... mountroot: waiting for device 10.11.12.13:/usr/home/elars/dst ... Mounting from nfs:10.11.12.13:/usr/home/elars/dst failed with error 19. Loader variables: vfs.root.mountfrom=nfs:10.11.12.13:/usr/home/elars/dst Manual root filesystem specification: fstype:device [options] Mount device using filesystem fstype and with the specified (optional) option list. eg. ufs:/dev/da0s1a zfs:tank cd9660:/dev/acd0 ro (which is equivalent to: mount -t cd9660 -o ro /dev/acd0 /) ? List valid disk boot devices . Yield 1 second (for background tasks) empty lineAbort manual input mountroot I did a tcpdump and no traffic shows up on the correct interface (em4). I guess I need to set yet another loader environment variable to indicate which interface I'd like to use. Looking at the source, I only see boot.netif.name, but setting that to em4 doesn't help either. Any further ideas? The interface doesn't have a name during loader stage. The kernel finds the interface to use based on the MAC address. You should set boot.netif.hwaddr as well in the kernel environment. -- Andre ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Jan 31, 2013, at 12:45, Andreas Nilsson andrn...@gmail.com wrote: Just a shot in the dark, did you actually tell it to do the root mount ro, or try with the nfs share as rw? ro Lars ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Jan 31, 2013, at 12:53, Andre Oppermann an...@freebsd.org wrote: The interface doesn't have a name during loader stage. The kernel finds the interface to use based on the MAC address. You should set boot.netif.hwaddr as well in the kernel environment. Done, no change. Here is what's in my loader environment: boot.netif.netmask 255.255.255.0 boot.netif.gateway 10.11.12.13 boot.nfsroot.server 10.11.12.13 boot.nfsroot.path/usr/home/elars/dst boot.netif.ip10.11.12.15 boot.netif.name em4 boot.netif.hwaddrxx:xx:xx:xx:xx:xx vfs.root.mountfrom nfs:10.11.12.13:/usr/home/elars/dst And here is what I see during boot: Trying to mount root from nfs:10.11.12.13:/usr/home/elars/dst []... mountroot: waiting for device 10.11.12.13:/usr/home/elars/dst ... Mounting from nfs:10.11.12.13:/usr/home/elars/dst failed with error 19. Lars ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Jan 31, 2013, at 12:53, Andre Oppermann an...@freebsd.org wrote: The interface doesn't have a name during loader stage. The kernel finds the interface to use based on the MAC address. You should set boot.netif.hwaddr as well in the kernel environment. Done, no change. Here is what's in my loader environment: boot.netif.netmask 255.255.255.0 boot.netif.gateway 10.11.12.13 boot.nfsroot.server 10.11.12.13 boot.nfsroot.path/usr/home/elars/dst boot.netif.ip10.11.12.15 boot.netif.name em4 boot.netif.hwaddrxx:xx:xx:xx:xx:xx vfs.root.mountfrom nfs:10.11.12.13:/usr/home/elars/dst And here is what I see during boot: Trying to mount root from nfs:10.11.12.13:/usr/home/elars/dst []... mountroot: waiting for device 10.11.12.13:/usr/home/elars/dst ... Mounting from nfs:10.11.12.13:/usr/home/elars/dst failed with error 19. Lars a shot in the dark, but is /usr/home/elars/dst properly exported? danny ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Jan 31, 2013, at 15:54, Daniel Braniss da...@cs.huji.ac.il wrote: a shot in the dark, but is /usr/home/elars/dst properly exported? Yep, the NFS mount works fine when I use BOOTP with a root-path option Lars ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Lars Eggert wrote: Hi, On Jan 30, 2013, at 22:43, Craig Rodrigues rodr...@crodrigues.org wrote: 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. the loader can export some environment variables (this is how I get the serial console working.) 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 Done. (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 Done. Now, there are some other environment variables you need to export from the loader. boot.netif.ip boot.netif.netmask boot.netif.gateway boot.nfsroot.server boot.nfsroot.path Done. I also ripped out all the BOOTP* options from the kernel. Here is the complete list of environment variables from the comment in sys/nfs/nfs_diskless.c: * The loader is expected to export the following environment variables: 149 * 150 * boot.netif.name name of boot interface 151 * boot.netif.ip IP address on boot interface 152 * boot.netif.netmask netmask on boot interface 153 * boot.netif.gateway default gateway (optional) 154 * boot.netif.hwaddr hardware address of boot interface 155 * boot.nfsroot.server IP address of root filesystem server 156 * boot.nfsroot.path path of the root filesystem on server 157 * boot.nfsroot.nfshandle NFS handle for root filesystem on server 158 * boot.nfsroot.nfshandlelen and length of this handle (for NFSv3 only) 159 * boot.nfsroot.options NFS options for the root filesystem Note that boot.nfsroot.nfshandle and boot.nfsroot.nfshandlelen are not easy to get. pxeboot does a Mount RPC against the NFS server to get them. (Probably the easiest way to find out what they are is to capture packets while doing a mount of the same path and then looking at the capture via wireshark.) For this method to work, you have to specify options NFS_BOOT, but not the BOOTP* ones for the kernel. However, this still fails: Trying to mount root from nfs:10.11.12.13:/usr/home/elars/dst []... mountroot: waiting for device 10.11.12.13:/usr/home/elars/dst ... Mounting from nfs:10.11.12.13:/usr/home/elars/dst failed with error 19. Loader variables: vfs.root.mountfrom=nfs:10.11.12.13:/usr/home/elars/dst As far as I can see, the current code does not know how to turn this into a root file handle via a Mount RPC. I think a non-trivial patch to sys/nfs/bootp_subr.c would be required. As such, the only other way to make it work is to use options NFS_ROOT and specify the root file handle in the environment variables, as above. (If I recall correctly, the root file handle is specified as a string of hex digits, but look in the code in sys/nfs/nfs_diskless.c to confirm this.) rick Manual root filesystem specification: fstype:device [options] Mount device using filesystem fstype and with the specified (optional) option list. eg. ufs:/dev/da0s1a zfs:tank cd9660:/dev/acd0 ro (which is equivalent to: mount -t cd9660 -o ro /dev/acd0 /) ? List valid disk boot devices . Yield 1 second (for background tasks) empty line Abort manual input mountroot I did a tcpdump and no traffic shows up on the correct interface (em4). I guess I need to set yet another loader environment variable to indicate which interface I'd like to use. Looking at the source, I only see boot.netif.name, but setting that to em4 doesn't help either. Any further ideas? Thanks, Lars ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Hi, On Jan 30, 2013, at 10:32, Eggert, Lars l...@netapp.com wrote: On Jan 29, 2013, at 20:22, Craig Rodrigues rodr...@crodrigues.org wrote: 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 MountpointFSType Options Dump Pass 10.11.12.13:/usr/home/elars/dst/ / nfs ro00 Thanks, will try that! doesn't work. The kernel never leaves the DHCP/BOOTP timeout for server-loop unless I hand out a root-path option via DHCP. I tried your tip above, I tried setting ROOTDEVNAME in the kernel, I created a /boot.config with -r in it on the NFS root - all to no avail. 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. Doesn't seem to work either. Lars ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Wed, 2013-01-30 at 09:32 +, Eggert, Lars wrote: Hi, On Jan 29, 2013, at 20:22, Craig Rodrigues rodr...@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. 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 MountpointFSType Options Dump Pass 10.11.12.13:/usr/home/elars/dst/ / nfs ro00 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. Just FYI, I believe the current behavior of BOOTP and BOOTP_NFSROOT is a bug, and I've entered a PR for it http://www.freebsd.org/cgi/query-pr.cgi?pr=175671 I also put a little effort into changing the behavior so that BOOTP without BOOTP_NFSROOT gets you an address and then moves on to use the ROOTDEVNAME you have configured, but I didn't have any success yet (it stays stuck in the state of waiting for the root path). I intend to get back to it after wrapping up some other work, if someone else doesn't get to it first. -- Ian ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Lars Eggert wrote: Hi, On Jan 29, 2013, at 20:22, Craig Rodrigues rodr...@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 rodr...@crodrigues.org ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Wed, Jan 30, 2013 at 1:32 AM, Eggert, Lars l...@netapp.com wrote: Hi, On Jan 29, 2013, at 20:22, Craig Rodrigues rodr...@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 MountpointFSType Options Dump Pass 10.11.12.13:/usr/home/elars/dst/ / nfs ro0 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 ro00 (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 rodr...@crodrigues.org ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On 1/30/13 1:32 AM, Eggert, Lars wrote: Hi, On Jan 29, 2013, at 20:22, Craig Rodrigues rodr...@crodrigues.org wrote: 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. your custom loader should have some way to set kernel environment values. it's a pretty basic requirement and, surprisingly, not that hard to do. ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Mon, Jan 28, 2013 at 7:13 AM, Eggert, Lars l...@netapp.com wrote: Hi, I'm trying to netboot a system where the root device is specified in the kernel via ROOTDEVNAME: Lars, I recommend that you do not use ROOTDEVNAME, and instead you should follow the instructions which I wrote and contributed to the FreeBSD handbook: PXE Booting with an NFS Root File System http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-pxe-nfs.html The content of this document is the same as the text file which Rick Macklem pointed out (I wrote that too). BTW, if you ever visit the Netapp campus in Sunnyvale, California, feel free to say hello, because I work around the corner from there. :) -- Craig Rodrigues rodr...@crodrigues.org ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Hi, On Jan 29, 2013, at 9:34, Craig Rodrigues rodr...@crodrigues.org wrote: I recommend that you do not use ROOTDEVNAME, and instead you should follow the instructions which I wrote and contributed to the FreeBSD handbook: PXE Booting with an NFS Root File System http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-pxe-nfs.html The content of this document is the same as the text file which Rick Macklem pointed out (I wrote that too). I had read both before, and they're very useful documents. Unfortunately, they don't fully apply to my case, since I'm not PXE-booting the system; it netboots the kernel from a custom loader. So once the kernel bootstraps, I need it to obtain an IP address and then NFS-mount root. BTW, if you ever visit the Netapp campus in Sunnyvale, California, feel free to say hello, because I work around the corner from there. :) -- Craig Rodrigues rodr...@crodrigues.org ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Jan 29, 2013, at 10:13, Lars Eggert l...@netapp.com wrote: On Jan 29, 2013, at 9:34, Craig Rodrigues rodr...@crodrigues.org wrote: I recommend that you do not use ROOTDEVNAME, and instead you should follow the instructions which I wrote and contributed to the FreeBSD handbook: PXE Booting with an NFS Root File System http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-pxe-nfs.html The content of this document is the same as the text file which Rick Macklem pointed out (I wrote that too). I had read both before, and they're very useful documents. Unfortunately, they don't fully apply to my case, since I'm not PXE-booting the system; it netboots the kernel from a custom loader. So once the kernel bootstraps, I need it to obtain an IP address and then NFS-mount root. (Whoops, hit send by mistake.) That's what I was trying to achieve with the BOOTP and BOOTP_WIRED_TO options. Hm, I wonder if I could simply use the custom loader to netboot tftpboot, and then follow your instructions... Will try. BTW, if you ever visit the Netapp campus in Sunnyvale, California, feel free to say hello, because I work around the corner from there. :) Am there about once a month, will do :-) Lars ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Tue, 2013-01-29 at 09:17 +, Eggert, Lars wrote: On Jan 29, 2013, at 10:13, Lars Eggert l...@netapp.com wrote: On Jan 29, 2013, at 9:34, Craig Rodrigues rodr...@crodrigues.org wrote: I recommend that you do not use ROOTDEVNAME, and instead you should follow the instructions which I wrote and contributed to the FreeBSD handbook: PXE Booting with an NFS Root File System http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-pxe-nfs.html The content of this document is the same as the text file which Rick Macklem pointed out (I wrote that too). I had read both before, and they're very useful documents. Unfortunately, they don't fully apply to my case, since I'm not PXE-booting the system; it netboots the kernel from a custom loader. So once the kernel bootstraps, I need it to obtain an IP address and then NFS-mount root. (Whoops, hit send by mistake.) That's what I was trying to achieve with the BOOTP and BOOTP_WIRED_TO options. Hm, I wonder if I could simply use the custom loader to netboot tftpboot, and then follow your instructions... Will try. I think that's what I used to do before I switched to configuring the boot file and root path via dhcp as well. I could've sworn I used BOOTP without BOOTP_NFSROOT, but perhaps that's just my muddled memory of what I tried to do that never worked out. I also think all of this is a bug. It seems to me that BOOTP without BOOTP_NFSROOT should obtain ip-related info from dhcp but use ROOTDEVNAME as configured, perhaps with any dhcp-provided root path as a fallback if there's a problem or ROOTDEVNAME is unconfigured. -- Ian ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Tue, Jan 29, 2013 at 1:17 AM, Eggert, Lars l...@netapp.com wrote: On Jan 29, 2013, at 10:13, Lars Eggert l...@netapp.com wrote: On Jan 29, 2013, at 9:34, Craig Rodrigues rodr...@crodrigues.org wrote: I had read both before, and they're very useful documents. Unfortunately, they don't fully apply to my case, since I'm not PXE-booting the system; it netboots the kernel from a custom loader. So once the kernel bootstraps, I need it to obtain an IP address and then NFS-mount root. Hi, What kind of architecture are you trying to do this on? Is this i386/amd64 or something else? I am not familiar with netboot compared to PXE. Is TFTP involved at all with netboot? What does your dhcpd configuration file look like? Also, are you using the FreeBSD loader, or something else? What kinds of customizations have you done on the 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. 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 MountpointFSType Options Dump Pass 10.11.12.13:/usr/home/elars/dst/ / nfs ro00 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 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 rodr...@crodrigues.org ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
mounting root from NFS via ROOTDEVNAME
Hi, I'm trying to netboot a system where the root device is specified in the kernel via ROOTDEVNAME: options BOOTP options BOOTP_NFSROOT options BOOTP_NFSV3 options BOOTP_COMPAT options BOOTP_WIRED_TO=em4 options ROOTDEVNAME=\nfs:10.11.12.13:/usr/home/elars/dst\ I was under the assumption that specifying a ROOTDEVNAME in the kernel config would override the root-path option in DHCP, or at least take effect when root-path wasn't provided via DHCP, but that doesn't seem to be the case. The system configures it's address correctly over em4, but then enters a loop: em4: link state changed to UP Received DHCP Offer packet on em4 from 0.0.0.0 (accepted) (no root path) Sending DHCP Request packet from interface em4 (XX:XX:XX:XX:XX:XX) Received DHCP Ack packet on em4 from 0.0.0.0 (accepted) (no root path) Received DHCP Ack packet on em4 from 0.0.0.0 (accepted) (no root path) DHCP/BOOTP timeout for server 255.255.255.255 Received DHCP Ack packet on em4 from 0.0.0.0 (accepted) (no root path) DHCP/BOOTP timeout for server 255.255.255.255 ... If I hand out a root path via DHCP the system boots fine, but the idea here is to be able to boot different root devices without needing to diddle dhcpd.conf. Can this be done? Thanks, Lars ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
On Mon, 2013-01-28 at 15:13 +, Eggert, Lars wrote: Hi, I'm trying to netboot a system where the root device is specified in the kernel via ROOTDEVNAME: options BOOTP options BOOTP_NFSROOT options BOOTP_NFSV3 options BOOTP_COMPAT options BOOTP_WIRED_TO=em4 options ROOTDEVNAME=\nfs:10.11.12.13:/usr/home/elars/dst\ I was under the assumption that specifying a ROOTDEVNAME in the kernel config would override the root-path option in DHCP, or at least take effect when root-path wasn't provided via DHCP, but that doesn't seem to be the case. The system configures it's address correctly over em4, but then enters a loop: em4: link state changed to UP Received DHCP Offer packet on em4 from 0.0.0.0 (accepted) (no root path) Sending DHCP Request packet from interface em4 (XX:XX:XX:XX:XX:XX) Received DHCP Ack packet on em4 from 0.0.0.0 (accepted) (no root path) Received DHCP Ack packet on em4 from 0.0.0.0 (accepted) (no root path) DHCP/BOOTP timeout for server 255.255.255.255 Received DHCP Ack packet on em4 from 0.0.0.0 (accepted) (no root path) DHCP/BOOTP timeout for server 255.255.255.255 ... If I hand out a root path via DHCP the system boots fine, but the idea here is to be able to boot different root devices without needing to diddle dhcpd.conf. Can this be done? Remove the BOOTP_NFSROOT option, it tells the bootp/dhcp code to keep querying the server until a root path is delivered. Without it, the ROOTDEVNAME option should get used (and I think even override a path from the server, if it delivers one). -- Ian ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Hi, On Jan 28, 2013, at 16:23, Ian Lepore i...@freebsd.org wrote: Remove the BOOTP_NFSROOT option, it tells the bootp/dhcp code to keep querying the server until a root path is delivered. Without it, the ROOTDEVNAME option should get used (and I think even override a path from the server, if it delivers one). no luck: em4: link state changed to UP Received DHCP Offer packet on em4 from 0.0.0.0 (accepted) (no root path) Sending DHCP Request packet from interface em4 (XX:XX:XX:XX:XX:XX) Received DHCP Ack packet on em4 from 0.0.0.0 (accepted) (no root path) DHCP/BOOTP timeout for server 255.255.255.255 Received DHCP Ack packet on em4 from 0.0.0.0 (accepted) (no root path) DHCP/BOOTP timeout for server 255.255.255.255 ... The only visible difference is that the first Received DHCP Ack packet line is now printed only once, instead of twice as in the previous log. Lars ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org
Re: mounting root from NFS via ROOTDEVNAME
Lars Eggert wrote: Hi, I'm trying to netboot a system where the root device is specified in the kernel via ROOTDEVNAME: options BOOTP options BOOTP_NFSROOT options BOOTP_NFSV3 options BOOTP_COMPAT options BOOTP_WIRED_TO=em4 options ROOTDEVNAME=\nfs:10.11.12.13:/usr/home/elars/dst\ I was under the assumption that specifying a ROOTDEVNAME in the kernel config would override the root-path option in DHCP, or at least take effect when root-path wasn't provided via DHCP, but that doesn't seem to be the case. The system configures it's address correctly over em4, but then enters a loop: em4: link state changed to UP Received DHCP Offer packet on em4 from 0.0.0.0 (accepted) (no root path) Sending DHCP Request packet from interface em4 (XX:XX:XX:XX:XX:XX) Received DHCP Ack packet on em4 from 0.0.0.0 (accepted) (no root path) Received DHCP Ack packet on em4 from 0.0.0.0 (accepted) (no root path) DHCP/BOOTP timeout for server 255.255.255.255 Received DHCP Ack packet on em4 from 0.0.0.0 (accepted) (no root path) DHCP/BOOTP timeout for server 255.255.255.255 ... If I hand out a root path via DHCP the system boots fine, but the idea here is to be able to boot different root devices without needing to diddle dhcpd.conf. Can this be done? Well, just to make it more interesting, there are 2 different ways an NFS root file system can be booted by the kernel. The other one can be configured by: - delete all options that start in BOOTP - add the options NFS_ROOT Now, the kernel will use information from a list of environment variables set by the loader, plus the values referenced to rootdevnames[0] and rootdevnames[1], if they are set. (The list of these environment variables is in a comment in sys/nfs/nfs_diskless.c and are normally set by pxeboot.) rootdevnames[0] gets set in nfs_diskless.c, but rootdevnames[1] does not. This source file has the magic for this way of doing it, as you might have guessed. I think rootdevnames[1] gets tried if rootdevnames[0] fails. You could try hacking sys/nfs/nfs_diskless.c and add a line to set rootdevnames[1] to ROOTDEVNAME, if it is defined. (#include opt_rootdevname.h so that it will be defined, if the option is specified.) I haven't tried this, but it might work? Btw, for the above to work, you need to use pxeboot and I think you'll need to have enough dhcpd setup so that it loads. (I'm not sure if option root-path is needed for pxeboot to get the loader going?) Short answer is, there may be a way to get this to work with a little source hacking, but it might be easier to just modify your dhcpd.conf;-) Btw, I use this document for how I set things up for the options NFS_ROOT version. http://people.freebsd.org/~rodrigc/pxe/freebsd_pxe.txt Good luck with it, rick ps: All BOOTP_NFSROOT does is tell the BOOTP version to use an NFS root and it will then expect the dhcp root-path option as you found out. Thanks, Lars ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org ___ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org