Raspberry Pi – Use your system on NFS

After you have submitted an article on the use of a USB key here, I wanted to offer you another way to start your Raspberry Pi : NFS.

NFS_Linux

NFS stands for Network File System. It's a network protocol to use a remote directory as a local file system. I give you the page Wikipedia pour plus d’informations techniques ūüôā

What ca well will be able to serve you ? Mon idée était de mettre à disposition sur mon Raspberry Pi qui me sert de serveur, a set of Linux distributions, then to start my Raspberry ft of test on one or the other depending on my choice/desires.

Instructions :

  1. Download the(the) distribution(s) that you want to use.
  2. Install on the server archives and unpack them.
    How to retrieve the contents of a distribution :

    1. You have your IMG file. Use the command file to learn the structure. It should be always the same :
      file <name of the file>.IMG

      Capture_d_écran_20_06_13_21_06What is important is the starting point of the second partition (startsector 122880) and its type (ID = 0 x 83 is the ext4)

    2. You can now mount the partition in a temporary directory with an offset equal to startsector multiplied by 512 :
      mkdir/tmp/img mount-t ext4 moebius - 1.1.0.img o offset = 62914560/tmp/img
    3. You now have access to content. You can copy it into the directory that will store your distributions. My home is/media/usbdrive/distributions :
      CP-r/tmp/img / * /media/usbdrive/distributions/moebius1.1.0
    4. In the directory newly created, modify the contents of the fstab file. In our example the file is /Media/usbdrive/distributions/moebius1.1.0/etc/fstab. Delete the line that tries to mount the main partition :
      Capture_d_écran_21_06_13_10_57
  3. Need to be available on the network this directory as a filesystem. Install NFS support for the kernel :
    apt - get install nfs-kernel-server
  4. Configure the directories to share. It is in the file /etc/exportfs :
    Capture_d_écran_21_06_13_09_23
  5. Update the NFS share tables :
    exportfs - av
  6. You can restart the services nfs and rpcbind
    nfs-kernel-server service restart
    nfs-common service restart
    rpcbind service restart
  7. We will test on other Raspberry POI that our file system is available. For this we must install the NFS client side tools :
    apt-get update && apt-get -y upgrade && apt - get install nfs-common
  8. You can test your server NFS in many ways :
    1. Mount your shared partition
      Mount.nfs4 192.168.1.18:/Media/usbdrive/distributions/moebius1.1.0/tmp/nfs
    2. Use rpcinfo to request information from your server
      Capture_d_écran_21_06_13_10_36
  9. You now have your NFS server. To use the filsystem, You must change side client, the file /boot/cmdline.txt to use this you just share. There are settings to change :
      1. root : the device mount point. Here it will be/dev/nfs
      2. rootfstype : type of mounting. Us nfs.
      3. nfsroot : the full address of the mount with options and more point. At home I use
        root = / dev/nfs nfsroot = 192.168.1.18:/Media/usbdrive/distributions/moebius1.1.0,UDP,= 3 ip = dhcp

        Thanks to This site for the info !

    Pensez √† sauvegarde votre fichier original ūüėČ

  10. Restart the client. And cross your fingers !

Some more information. Raspbian I have problem at the moment because he wants to force a control of the system to the boot and asks the root password that does not exist. For Moebius I didn't have worries I connect.

At home I have three shared distributions. I created a symbolic link raspberry to that I want to use. On my card I used the name of the link instead of the full path. This allows me to change distribution from my server without having to go to the SD card (practice in case of crash).

For those who do not have many Raspberry, you have tools on Windows and Mac OS for your NFS server. Under Linux, the procedure is almost identical to that of article.

Have fun !

Like this article ? Bear with me on patreon!

You may also like...