Difference between revisions of "Network File System configuration"

From ArmadeusWiki
Jump to: navigation, search
m (NFS usage on your Armadeus board)
(Troubleshooting)
 
(45 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
==Introduction==
 
==Introduction==
  
On this page, you will find usefull informations to configure NFS ([[wikipedia:Network_File_System_(protocol)| Network File System]]) on your Host and your Target.
+
On this page, you will find usefull informations to configure NFS ([[wikipedia:Network_File_System_(protocol)|Network File System]]) on your Host and your Target.
  
 
==NFS server on your development Host==
 
==NFS server on your development Host==
Line 8: Line 8:
 
* On Fedora, NFS is part of your distribution so you normally don't need to install it.
 
* On Fedora, NFS is part of your distribution so you normally don't need to install it.
 
* On Ubuntu/Kubuntu:
 
* On Ubuntu/Kubuntu:
$ sudo apt-get install nfs-user-server
 
or if you prefer:
 
 
  $ sudo apt-get install nfs-kernel-server
 
  $ sudo apt-get install nfs-kernel-server
 +
* On OpenSUSE:
 +
$ sudo zypper install yast2-nfs-server
 +
* On Gentoo:
 +
# emerge -av nfs-utils
  
 +
You can also take a look at the [https://wiki.gentoo.org/wiki/Nfs-utils gentoo wiki]
 
===Configuration===
 
===Configuration===
 
====/etc/exports====
 
====/etc/exports====
You have to configure the directory where you will store the files you want to share accross the network.
+
* You have to declare the directory where you're going to store the files you want to share accross the network. For that you have to modify the '''/etc/exports''' file with (for example):
For that you have to modify the '''/etc/exports''' file (for example):
+
<pre class="host">
# Directory for Armadeus:
+
$ sudo vim /etc/exports
/local/export    192.168.0.0/255.255.0.0(ro,no_root_squash,sync)
+
</pre>
(In that case your Host will authorize all client from the subnet 192.168.*.* to access /local/export in read only mode)
+
and add it (at the end of the file):
 +
<source lang="bash">
 +
...
 +
# Directory for Armadeus:
 +
/local/export    192.168.0.0/255.255.255.0(ro,no_root_squash,sync)
 +
...
 +
</source>
 +
:In that case your Host will authorize all client from the subnet 192.168.*.* to access ''/local/export'' in '''read only''' mode. If you want read/write access from your APF to your exported dir, then replace ''ro'' with ''rw''.<br>
 +
* In order to use the same folder through TFTP and NFS, using the default U-Boot scripts for example, it recommended to export your /tftpboot folder as well:
 +
<source lang="bash">
 +
...
 +
# Directory for Armadeus:
 +
/local/export    192.168.0.0/255.255.255.0(ro,no_root_squash,sync)
 +
/tftpboot    192.168.0.0/255.255.255.0(ro,no_root_squash,sync)
 +
...
 +
</source>
 +
* If not existing, create your export directory (for example):
 +
<pre class="host">
 +
$ sudo mkdir -p /local/export
 +
$ sudo chown -R $USER:$GROUP /local/export/
 +
</pre>
 +
 
 +
====/etc/hosts====
 +
* You have to declare your APF/OPOS board in the PC hosts list, to fully support NFS access from U-Boot. For such purpose you have to update the ''/etc/hosts'' file with your preferred editor (as root):
 +
<pre class="host">
 +
$ sudo vim /etc/hosts
 +
</pre>
 +
and add the IP address of your board after the localhost definition for example :
 +
<source lang="bash">
 +
127.0.0.1 localhost
 +
192.168.0.10 apf
 +
...
 +
</source>
  
 
====Restart of NFS server====
 
====Restart of NFS server====
* '''On Fedora:'''
+
{| border="1" cellpadding="5" cellspacing="0" summary="Restart of NFS server depending on your distribution"
 +
|- style="background:#efefef;"
 +
! '''On Fedora''' || '''On Ubuntu/Kubuntu/debian'''  || '''On OpenSUSE''' || '''On Gentoo'''
 +
|-
 +
 
 +
|<pre class="host">
 
  # /sbin/service nfs restart
 
  # /sbin/service nfs restart
 +
</pre>
 
Next time you boot, you can check your NFS server status with:
 
Next time you boot, you can check your NFS server status with:
 +
<pre class="host">
 
  # /sbin/service nfs status
 
  # /sbin/service nfs status
 +
</pre>
 
and if not started then:
 
and if not started then:
 +
<pre class="host">
 
  # /sbin/service nfs start
 
  # /sbin/service nfs start
 +
</pre>
  
* '''On Ubuntu/Kubuntu:'''
+
|| <pre class="host">
$ sudo /etc/init.d/nfs-user-server restart
+
or
+
 
  $ sudo /etc/init.d/nfs-kernel-server restart
 
  $ sudo /etc/init.d/nfs-kernel-server restart
 +
</pre>
 
Next time you boot, you can check your NFS server status with:
 
Next time you boot, you can check your NFS server status with:
System Settings->System services
+
''System Settings->System services''
 
+
|| <pre class="host">
* '''On OpenSUSE'''
+
 
  # /etc/init.d/nfsserver restart
 
  # /etc/init.d/nfsserver restart
 +
</pre>
 +
 +
|| <pre class="host">
 +
# /etc/init.d/nfs restart
 +
</pre>
 +
|}
  
 
==NFS usage on your Armadeus board==
 
==NFS usage on your Armadeus board==
  
 
===Mount the NFS partition manually ===
 
===Mount the NFS partition manually ===
 
+
* check if mount point is existing (for example we will take ''/mnt/nfs''):
* create a mount point (for example):
+
 
<pre class="apf">
 
<pre class="apf">
  # mkdir -p /mnt/host
+
# ls /mnt
 +
</pre>
 +
* if not existing, create the mount point:
 +
<pre class="apf">
 +
  # mkdir -p /mnt/nfs
 
</pre>
 
</pre>
 
* mount it (for example):
 
* mount it (for example):
 
<pre class="apf">
 
<pre class="apf">
  # mount -t nfs 192.168.0.2:/local/export /mnt/host
+
  # mount -t nfs 192.168.0.2:/local/export /mnt/nfs
 +
</pre>
 +
Here 192.168.0.2 is your Host IP address and ''/local/export'' the name of your Host directory you want to mount.
 +
 
 +
{{Note| On some nfs server (for exemple with debian wheezy) there is a warning when we mount nfs partition. But the filesystem is mounted :
 +
<pre class="apf">
 +
# mount /mnt/nfs/
 +
svc: failed to register lockdv1 RPC service (errno 97).
 
</pre>
 
</pre>
If 192.168.0.2 is your Host IP address and ''/local/export'' the name of your Host directory you want to mount.
+
}}
  
 
===Mount the NFS partition automatically at each boot from FLASH===
 
===Mount the NFS partition automatically at each boot from FLASH===
  
* be sure to have the latest available software (>=armadeus2.0 or latest SVN)
 
 
* login to your Armadeus board as root
 
* login to your Armadeus board as root
 
* open the '''/etc/fstab''' file and add this line:
 
* open the '''/etc/fstab''' file and add this line:
 
  <host-ip>:/<path-to-shared-folder> /mnt/<path-to-mount-folder> nfs hard,intr,rsize=8192,wsize=8192 0 0
 
  <host-ip>:/<path-to-shared-folder> /mnt/<path-to-mount-folder> nfs hard,intr,rsize=8192,wsize=8192 0 0
 
example:
 
example:
  192.168.0.2:/local/export /mnt/host nfs hard,intr,rsize=8192,wsize=8192 0 0
+
  192.168.0.2:/local/export /mnt/nfs nfs hard,intr,rsize=8192,wsize=8192 0 0
 
* check your modification:
 
* check your modification:
 
<pre class="apf">
 
<pre class="apf">
  # mount /mnt/host
+
  # mount /mnt/nfs
 
</pre>
 
</pre>
 
* reboot your board
 
* reboot your board
Line 71: Line 129:
 
<pre class="apf">
 
<pre class="apf">
 
  # df
 
  # df
  # ls /mnt/host
+
  # ls /mnt/nfs
 
</pre>
 
</pre>
 +
 
When you have a problem, verify that the NFS server is running on the host:
 
When you have a problem, verify that the NFS server is running on the host:
<pre class="host">
+
{| border="1" cellpadding="5" cellspacing="0" summary="Status of NFS server depending on your distribution"
$ /etc/init.d/nfs-kernel-server status
+
|- style="background:#efefef;"
</pre>
+
! '''On Fedora''' || '''On Ubuntu/Kubuntu/debian'''  || '''On OpenSUSE''' || '''On Gentoo'''
or
+
|-
<pre class="host">
+
 
 +
| <pre class="host">
 
  $ /sbin/service nfs status
 
  $ /sbin/service nfs status
 
</pre>
 
</pre>
 +
 +
||<pre class="host">
 +
$ /etc/init.d/nfs-kernel-server status
 +
</pre>
 +
|| 
 +
 +
|| 
 +
|}
  
 
===Boot from NFS===
 
===Boot from NFS===
* on your Host, expand generated rootfs image to your NFS export dir (for example if your NFS export file is ''/local/export'' on your Host):
+
This boot procedure is usefull to test a modified rootfs and/or a linux kernel keeping safe the original flash memory content of your board.
  [ ]$ sudo tar xvf buildroot/binaries/apf9328/apf9328-rootfs.arm.tar -C /local/export
+
* on your Host, expand generated rootfs image to your NFS export dir (for example if your NFS export dir is ''/tftpboot'' on your Host) and you want to boot on it using the U-Boot script nfsboot:
* on your target, in U-Boot, set the ''rootpath'' envt variable accordingly:
+
<pre class=host>
 +
$ make shell_env
 +
$ source armadeus_env.sh
 +
$ sudo mkdir -p /tftpboot/$ARMADEUS_BOARD_NAME-root/boot
 +
  $ sudo tar xvf $ARMADEUS_ROOTFS_TAR -C /tftpboot/$ARMADEUS_BOARD_NAME-root
 +
</pre>
 +
* The copy of the Linux kernel to the NFS ''/boot'' folder, makes possible to also download it with NFS when booting the board:
 +
<pre class=host>
 +
$ sudo cp $ARMADEUS_BINARIES/$ARMADEUS_BOARD_NAME-linux.bin /tftpboot/$ARMADEUS_BOARD_NAME-root/boot/
 +
</pre>
 +
* With recent (3.10+) kernels, you also have to copy the Device Tree blobs:
 +
<pre class=host>
 +
$ sudo mkdir -p /tftpboot/$ARMADEUS_BOARD_NAME-root/boot/dtbs
 +
$ sudo cp $ARMADEUS_BINARIES/*.dtb /tftpboot/$ARMADEUS_BOARD_NAME-root/boot/dtbs/
 +
</pre>
 +
 
 +
* On your board, in U-Boot, check if the ''rootpath'' envt variable is set accordingly:
 +
<pre class="apf">
 +
BIOS> printenv rootpath
 +
</pre>
 +
* If not, then set it (by default U-boot is configured to use the following path ''/tftpboot/apfXXXX-root'') where apfXXXX may be apf9328, apf27, apf28, apf51, apf6:
 
<pre class="apf">
 
<pre class="apf">
  BIOS> setenv rootpath /local/export
+
  BIOS> setenv rootpath /tftpboot/${board_name}-root
 
</pre>
 
</pre>
 
* save it:
 
* save it:
Line 99: Line 187:
  
 
===Summary of the required Packages:===
 
===Summary of the required Packages:===
* portmap (buildroot)
+
* portmap (Buildroot)
 
* nfs (busybox)
 
* nfs (busybox)
 
* nfs support (Linux, activated by default in Armadeus configuration)
 
* nfs support (Linux, activated by default in Armadeus configuration)
  
==Troubleshooting:==
+
==Troubleshooting==
  
*1] If nfsd and mountd daemon are not running on your Host, then you will get a message like:
+
===RPC: Program not registered===
# mount: RPC: Program not registered
+
* If ''nfsd'' and ''mountd'' daemons are not running on your Host, then you will get a message like:
In that case, restart the NFS service on your Host (see above)
+
<pre class="apf">
*2] To successfully mount a NFS drive, portmap daemon should be running on your target, if not system will hang during some minutes when you launch the mount !!
+
mount: RPC: Program not registered
To check if portmap is running, look at the running processes:
+
</pre>
 +
* In that case, restart the NFS service on your Host (see [[Network_File_System_configuration#Restart_of_NFS_server|above]]).
 +
 
 +
===Portmap/RPCbind===
 +
* To successfully mount a NFS drive, ''portmap''/''rpcbind'' daemon should be running on your APF/OPOS, if not, system will hang during some minutes when you launch the mount !!
 +
To check if ''portmap''/''rpcbind'' is running, look at the running processes:
 +
<pre class="apf">
 
  # ps faux
 
  # ps faux
If portmap is not listed, then launch it manually:
+
</pre>
  # /etc/init.d/S14portmap
+
If ''portmap/rpcbind'' is not listed, then launch it manually or install it:
 +
<pre class="apf"
 +
  # /etc/init.d/S13portmap
 +
</pre>
 +
* Note: ''portmap'' is obsolete since 2017
 +
 
 +
===Connection refused===
 +
* If you get this on your APF when trying to mount:
 +
<pre class="apf">
 +
mount: mounting 192.168.0.2:/local/export on /mnt/nfs/ failed: Connection refused
 +
</pre>
 +
* then your kernel might need some extra options:
 +
<pre class="apf">
 +
mount -o port=2049,nolock,proto=tcp 192.168.0.2:/local/export /mnt/nfs/
 +
</pre>
 +
 
 +
===Kernel debug===
 +
* If none of the above workarounds was successful -> no luck ! :-) You can still activate NFS debugging by recompiling your kernel with CONFIG_SUNRPC_DEBUG options and use ''setenv extrabootargs nfsrootdebug'' in U-Boot. And then you dig...
  
 
==NFS Server under Windows==
 
==NFS Server under Windows==
For those who want to use the NFS service on Windows, a small and FREE NFS server is available here:
+
For those who want to use the NFS service on Windows, a small and FREE NFS server is available [http://www.freedownloadscenter.com/Utilities/Misc__Utilities/nfsAxe.html here].
http://www.freedownloadscenter.com/Utilities/Misc__Utilities/nfsAxe.html
+
  
 
==Links==
 
==Links==
 
* http://www.denx.de/wiki/view/DULG/SystemSetup#Section_4.8.
 
* http://www.denx.de/wiki/view/DULG/SystemSetup#Section_4.8.
* [[SSH]]
 
 
 
{{LanguageBar|Network_Configuration|Configuration_Réseau|Netzwerk_Konfiguration}}
 
  
 
[[Category:Network]]
 
[[Category:Network]]

Latest revision as of 12:17, 1 February 2022

Introduction

On this page, you will find usefull informations to configure NFS (Network File System) on your Host and your Target.

NFS server on your development Host

Installation

  • On Fedora, NFS is part of your distribution so you normally don't need to install it.
  • On Ubuntu/Kubuntu:
$ sudo apt-get install nfs-kernel-server
  • On OpenSUSE:
$ sudo zypper install yast2-nfs-server
  • On Gentoo:
# emerge -av nfs-utils

You can also take a look at the gentoo wiki

Configuration

/etc/exports

  • You have to declare the directory where you're going to store the files you want to share accross the network. For that you have to modify the /etc/exports file with (for example):
$ sudo vim /etc/exports

and add it (at the end of the file):

...
# Directory for Armadeus:
/local/export     192.168.0.0/255.255.255.0(ro,no_root_squash,sync)
...
In that case your Host will authorize all client from the subnet 192.168.*.* to access /local/export in read only mode. If you want read/write access from your APF to your exported dir, then replace ro with rw.
  • In order to use the same folder through TFTP and NFS, using the default U-Boot scripts for example, it recommended to export your /tftpboot folder as well:
...
# Directory for Armadeus:
/local/export     192.168.0.0/255.255.255.0(ro,no_root_squash,sync)
/tftpboot     192.168.0.0/255.255.255.0(ro,no_root_squash,sync)
...
  • If not existing, create your export directory (for example):
$ sudo mkdir -p /local/export
$ sudo chown -R $USER:$GROUP /local/export/

/etc/hosts

  • You have to declare your APF/OPOS board in the PC hosts list, to fully support NFS access from U-Boot. For such purpose you have to update the /etc/hosts file with your preferred editor (as root):
$ sudo vim /etc/hosts

and add the IP address of your board after the localhost definition for example :

127.0.0.1	localhost
192.168.0.10	apf
...

Restart of NFS server

On Fedora On Ubuntu/Kubuntu/debian On OpenSUSE On Gentoo
 # /sbin/service nfs restart

Next time you boot, you can check your NFS server status with:

 # /sbin/service nfs status

and if not started then:

 # /sbin/service nfs start
 $ sudo /etc/init.d/nfs-kernel-server restart

Next time you boot, you can check your NFS server status with: System Settings->System services

 # /etc/init.d/nfsserver restart
 # /etc/init.d/nfs restart

NFS usage on your Armadeus board

Mount the NFS partition manually

  • check if mount point is existing (for example we will take /mnt/nfs):
# ls /mnt
  • if not existing, create the mount point:
 # mkdir -p /mnt/nfs
  • mount it (for example):
 # mount -t nfs 192.168.0.2:/local/export /mnt/nfs

Here 192.168.0.2 is your Host IP address and /local/export the name of your Host directory you want to mount.

Note Note: On some nfs server (for exemple with debian wheezy) there is a warning when we mount nfs partition. But the filesystem is mounted :
# mount /mnt/nfs/
svc: failed to register lockdv1 RPC service (errno 97).


Mount the NFS partition automatically at each boot from FLASH

  • login to your Armadeus board as root
  • open the /etc/fstab file and add this line:
<host-ip>:/<path-to-shared-folder> /mnt/<path-to-mount-folder> nfs hard,intr,rsize=8192,wsize=8192 0 0

example:

192.168.0.2:/local/export /mnt/nfs nfs hard,intr,rsize=8192,wsize=8192 0 0
  • check your modification:
 # mount /mnt/nfs
  • reboot your board
 # reboot
  • and enjoy the result
 # df
 # ls /mnt/nfs

When you have a problem, verify that the NFS server is running on the host:

On Fedora On Ubuntu/Kubuntu/debian On OpenSUSE On Gentoo
 $ /sbin/service nfs status
 $ /etc/init.d/nfs-kernel-server status

Boot from NFS

This boot procedure is usefull to test a modified rootfs and/or a linux kernel keeping safe the original flash memory content of your board.

  • on your Host, expand generated rootfs image to your NFS export dir (for example if your NFS export dir is /tftpboot on your Host) and you want to boot on it using the U-Boot script nfsboot:
 $ make shell_env
 $ source armadeus_env.sh
 $ sudo mkdir -p /tftpboot/$ARMADEUS_BOARD_NAME-root/boot
 $ sudo tar xvf $ARMADEUS_ROOTFS_TAR -C /tftpboot/$ARMADEUS_BOARD_NAME-root
  • The copy of the Linux kernel to the NFS /boot folder, makes possible to also download it with NFS when booting the board:
 $ sudo cp $ARMADEUS_BINARIES/$ARMADEUS_BOARD_NAME-linux.bin /tftpboot/$ARMADEUS_BOARD_NAME-root/boot/
  • With recent (3.10+) kernels, you also have to copy the Device Tree blobs:
 $ sudo mkdir -p /tftpboot/$ARMADEUS_BOARD_NAME-root/boot/dtbs
 $ sudo cp $ARMADEUS_BINARIES/*.dtb /tftpboot/$ARMADEUS_BOARD_NAME-root/boot/dtbs/
  • On your board, in U-Boot, check if the rootpath envt variable is set accordingly:
 BIOS> printenv rootpath
  • If not, then set it (by default U-boot is configured to use the following path /tftpboot/apfXXXX-root) where apfXXXX may be apf9328, apf27, apf28, apf51, apf6:
 BIOS> setenv rootpath /tftpboot/${board_name}-root
  • save it:
 BIOS> saveenv
  • then boot with:
 BIOS> run nfsboot

Summary of the required Packages:

  • portmap (Buildroot)
  • nfs (busybox)
  • nfs support (Linux, activated by default in Armadeus configuration)

Troubleshooting

RPC: Program not registered

  • If nfsd and mountd daemons are not running on your Host, then you will get a message like:
mount: RPC: Program not registered
  • In that case, restart the NFS service on your Host (see above).

Portmap/RPCbind

  • To successfully mount a NFS drive, portmap/rpcbind daemon should be running on your APF/OPOS, if not, system will hang during some minutes when you launch the mount !!

To check if portmap/rpcbind is running, look at the running processes:

 # ps faux

If portmap/rpcbind is not listed, then launch it manually or install it:

* Note: ''portmap'' is obsolete since 2017

===Connection refused===
* If you get this on your APF when trying to mount:
<pre class="apf">
mount: mounting 192.168.0.2:/local/export on /mnt/nfs/ failed: Connection refused
  • then your kernel might need some extra options:
mount -o port=2049,nolock,proto=tcp 192.168.0.2:/local/export /mnt/nfs/

Kernel debug

  • If none of the above workarounds was successful -> no luck ! :-) You can still activate NFS debugging by recompiling your kernel with CONFIG_SUNRPC_DEBUG options and use setenv extrabootargs nfsrootdebug in U-Boot. And then you dig...

NFS Server under Windows

For those who want to use the NFS service on Windows, a small and FREE NFS server is available here.

Links