mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Roland Hieber <rhi@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Roland Hieber <rhi@pengutronix.de>
Subject: [PATCH 2/2] defaultenv: boot/net: allow customising NFS port and path
Date: Fri, 10 Feb 2023 23:48:31 +0100	[thread overview]
Message-ID: <20230210224831.2597135-2-rhi@pengutronix.de> (raw)
In-Reply-To: <20230210224831.2597135-1-rhi@pengutronix.de>

There are use cases where the port and mount path of the NFS root need
to be changed from the default values, e.g. with the userspace NFS
daemon used by 'ptxdist nfsroot', which tells you:

    Mount rootfs with nfsroot=/root,v3,tcp,port=13049,mountport=13049

(The port number can vary of course, depending on how many users on your
devel server have already started unfsd at the same time.)

Support such use cases by introducing two new variables for the port
number and the mount path, which get inserted into the kernel command
line. Use the old default mount path as fallback when the new variable
is not set.

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
---
 Documentation/user/networking.rst     | 10 ++++++++++
 defaultenv/defaultenv-2-base/boot/net | 11 ++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/Documentation/user/networking.rst b/Documentation/user/networking.rst
index 6bd16ea8d1bd..e95957c0a26a 100644
--- a/Documentation/user/networking.rst
+++ b/Documentation/user/networking.rst
@@ -53,6 +53,16 @@ device:
 | global.net.nameserver        | ipv4 address | The DNS server used for resolving host names.         |
 |                              |              | May be set by DHCP.                                   |
 +------------------------------+--------------+-------------------------------------------------------+
+| global.net.nfspath           | string       | If set, determines the mount path of the root         |
+|                              |              | file system on the NFS server.                        |
+|                              |              | If not set, the default value                         |
+|                              |              | ``/home/${global.user}/nfsroot/${global.hostname}``   |
+|                              |              | is used.                                              |
++------------------------------+--------------+-------------------------------------------------------+
+| global.net.nfsport           | short        | If set, determines the port of the NFS server         |
+|                              |              | (the ``mountport`` and ``port`` arguments of the      |
+|                              |              | ``nfsroot`` parameter in the kernel command line).    |
++------------------------------+--------------+-------------------------------------------------------+
 | global.net.ifup_force_detect | boolean      | Set to true if your network device is not             |
 |                              |              | detected automatically during start (i.e. for         |
 |                              |              | USB network adapters).                                |
diff --git a/defaultenv/defaultenv-2-base/boot/net b/defaultenv/defaultenv-2-base/boot/net
index e79432eb277c..236955ef6fed 100644
--- a/defaultenv/defaultenv-2-base/boot/net
+++ b/defaultenv/defaultenv-2-base/boot/net
@@ -22,7 +22,16 @@ initramfs="${path}/${global.user}-initramfs-${global.hostname}"
 if [ -f "${initramfs}" ]; then
 	global.bootm.initrd="$initramfs"
 else
-	nfsroot="${nfsserver}:/home/${global.user}/nfsroot/${global.hostname}"
+	if [ -z "${global.net.nfspath}" ]; then
+		nfsroot="${nfsserver}:/home/${global.user}/nfsroot/${global.hostname}"
+	else
+		nfsroot="${nfsserver}:${global.net.nfspath}"
+	fi
+
+	if [ -n "${global.net.nfsport}" ]; then
+		nfsroot="${nfsroot},port=${global.net.nfsport},mountport=${global.net.nfsport}"
+	fi
+
 	ip_route_get -b ${global.net.server} global.linux.bootargs.dyn.ip
 	global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
 fi
-- 
2.30.2




  reply	other threads:[~2023-02-10 22:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-10 22:48 [PATCH 1/2] Documentation: networking: resize reStructuredText table Roland Hieber
2023-02-10 22:48 ` Roland Hieber [this message]
2023-02-13  7:42   ` [PATCH 2/2] defaultenv: boot/net: allow customising NFS port and path Sascha Hauer
2023-02-13 11:38     ` Roland Hieber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230210224831.2597135-2-rhi@pengutronix.de \
    --to=rhi@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox