Page MenuHomeFreeBSD

nfs: skip bootpc when vfs.root.mountfrom is other than nfs

Authored by alfredo on Apr 29 2022, 9:22 PM.



If "vfs.root.mountfrom" is set and the value is something other
than "nfs:*", it means the user doesn't want to mount root via nfs,
there's no reason to continue with bootpc

The powerpcspe kernel (MPC85XXSPE), compiled with BOOTP_NFSROOT
by default, gets stuck on bootpc/dhcp request loop when no DHCP
server is available on the network, even when user specifies a
local disk via "vfs.root.mountfrom" kernel parameter.

MFC after: 2 weeks
Sponsored by: Instituto de Pesquisas Eldorado (

Test Plan

test powerpcspe kernel under QEMU:

with "vfs.root.mountfrom" set to NFS
with "vfs.root.mountfrom" set to local partition (virtio-scsi)
without "vfs.root.mountfrom" and DHCP server on network
without "vfs.root.mountfrom" and without DHCP server on network

Diff Detail

rG FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

alfredo added a reviewer: rmacklem.
alfredo added a project: PowerPC.
sjg added inline comments.

Where might nfs: appear if not at the start of the string?

Beyond changing strstr() to a check for "nfs:" at the beginning of the
string, as suggested by sjg@, I don't see a problem with this.

However, I do not do diskless booting or know anything about
how vfs.root.mountroot is used, so I do not feel qualified to
review this. Maybe sjg@ could do so?

use strncmp instead of strstr in order to match only the beginning of the string

updated, thanks!

@rmacklem, 'vfs.root.mountroot' is used as a kernel parameter to specify (or override) where is the root filesystem to be mounted and its partition type. It's usually something like "vfs.root.mountroot=ufs:/dev/da0s1a" if you use a local disk, or "vfs.root.mountroot=nfs:" if using nfs.

It really needs someone familiar with bootstrapping to review this.
(Except for being the nfs case, it really has nothing to do with nfs.)

I think this is fine as is.
There's no need to check for nfs in the middle of a string, unless there's some use case I'm unaware of...


I'm agnostic on strncmp vs strstr. What would be fore nfs:?

This revision is now accepted and ready to land.Mon, May 30, 6:27 PM
alfredo added inline comments.

yes, it's expected to have "nfs:" right in the beginning. thanks!