Saturday, March 31, 2018

NFS setup for Rpi

This will show you how to setup an NFS server and client for the Raspberry Pi. We need one Pi to act as the NFS server and one or more other Pis will be the clients. I have called my fictitious NFS server “pistore” and it is using an IP address of 192.168.0.99.


This tutorial was done using the current Raspbian release at the time of writing - Stretch 9.4.


All of this is done using the command line or terminal session so you can do this even on a “headless” Pi - that is one that doesn’t have a screen or keyboard.


We are using nano to edit some files. To save your changes in nano press Control-O and it will prompt for the filename with the one you used to open it as a default. Just press the Enter key. To exit nano press Control-X.



Configure NFS Server


1.      Install NFS server
At a command prompt type:
sudo apt update
sudo apt install nfs-kernel-server -y
 
2.      Create the NFS server shared folder
Create a mount-point. You can use an existing directory if you want.
sudo mkdir /mnt/nfsserver


Give it liberal permissions.
sudo chmod -R 777 /mnt/nfsserver
 
3.      Edit the NFS exports file
This is where you configure the paths to share and their permissions.
sudo nano /etc/exports


The syntax is: Share directory + space + IP address + Access
Where
/mnt/nfsserver represents the path to share on the Raspberry Pi. The share directory.


IP represents the IP address or range


Access restricts certain types of access like read and write (rw) or read only (ro). It is contained within brackets
/mnt/nfsserver IP(access)


Using a asterisk you can grant access to all IP addresses which is not recommended.
/mnt/nfsserver *(rw,sync,no_subtree_check)


You can also specify a single Pi by its IP address
/mnt/nfsserver 192.168.0.34(rw,sync,no_subtree_check)


You can choose to restrict access to a whole IP range like your entire home network. The /24 represents the subnet mask of your network.
/mnt/nfsserver 192.168.0.0/24(rw,sync,no_subtree_check)


If you want read-only access for your NFS clients change the rw to ro
/mnt/nfsserver 192.168.0.0/24(ro,sync,no_subtree_check).


Its recommended to use (rw,sync,no_subtree_check) for access, unless you want to grant read-only access. exportfs will give warning messages if subtree_check is not specified.


 
4.      Tell NFS to read the exports file
sudo exportfs -a
 
5.      Check it started
To check the status of the service you can do the following:
sudo service nfs-server status


It should look something like this
Mar 30 20:39:02 pistore systemd[1]: Starting NFS server and services...
Mar 30 20:39:02 pistore systemd[1]: Started NFS server and services.


If it has errors they are likely to be exportfs lines that it doesn't like. There should only be a single space between the path /mnt/nfsserver and the IP address. The options contained within the brackets should be after the IP address (ie there is no space between the IP address and the bracket).


After you've fixed up the exports file you can restart it by:
sudo service nfs-server start
 
6.      Check NFS is exported
To check you are exporting the share use the following command.
sudo exportfs


It should respond with something like this:
/mnt/nfsserver  192.168.0.0/24
 
7.      Firewall
If you are using a firewall you will need to open port 2049 (tcp and udp) so the clients can access your NFS server.


The NFS server should have a static IP address otherwise it may end up with a different IP address every time it starts up and the clients won’t be able to find it.


 
Configure NFS Client
This is done on each of client Pis.

1.      Add the name of the NFS server

Because I don't remember IP addresses all that well I am going to add pistore, the name of my fictitious NFS server, to /etc/hosts, that way I can just refer to it by its name.
sudo nano /etc/hosts


Add the IP address and name to the end of the file
192.168.0.99  pistore 


2.      Create the mount point
Create a mount-point for our NFS share, this is the local directory you use to access the directory on the NFS server
sudo mkdir -p /mnt/nfs

Change owner of the NFS mount point to user pi
sudo chown -R pi:pi /mnt/nfs

3.      Test it
Test mounting the NFS share on your Raspberry Pi. Replace the first section with the IP address of your NFS server or use its name and its share path.
sudo mount pistore:/mnt/nfsserver /mnt/nfs

4.      Automount the share
To make the NFS share mount automatically on boot-up edit the fstab file.
sudo nano /etc/fstab


Add this line but adjust your IP/NFS server name and mount points. rw stands for read/write so if you only want read access change the rw to ro (read only)
pistore:/mnt/nfsserver   /mnt/nfs   nfs    rw  0  0



Now reboot the Pi and see if you can access /mnt/nfs



Tuesday, March 27, 2018

Pi^4 case Mk II

This is the Pi^4 case Mk II. It holds four Raspberry Pi side by side, hence the name - Pi to the power of four.

It has the Pi raised off the base so there is room for air to flow underneath. They are now screwed into the base to make them more secure. Two fans on the top provide lots of airflow to keep the temperatures down.

Click on the pictures to see the full-sized image.



Here is a picture with the top off. As you can see there is room for the power cables to plug into each Raspberry Pi.


And here is the reason for the delay in completing this project. The Raspberry Pi uses M2.5 screw holes so I had to obtain these screws which had to come via post.


Next I would like to see what can be done with the electrical side of things.

Friday, March 23, 2018

Raspberry Pi3B+

The Raspberry Pi Foundation released a new Pi3, known as the Pi3 model B+.

Its a bit faster than the Pi3 so after reading a few reviews I decided to update my Pi cluster. I ordered 11 of them to replace my existing set of Pi3's. I asked for a discount seeing as I was buying 11. No dice so I placed the order anyway. A couple of hours after placing the order they gave me a quote with the price reduced by 50 cents. Great! I had already placed the order so couldn't change it.



And here is one out of its box the wrong way round so you can see what they look like upside-down. Pretty much the same as the Pi3 model B but a few differences.

1. The SoC (System on a Chip) has a metal heat-spreader.
2. The WiFi and Bluetooth module has a metal shield over it (the one with the Pi logo).
3. There are 4 pins for the PoE (Power over Ethernet) module that you can buy separately.



And here are the heatsinks. The box comes with 8 inside. Unfortunately I only had 5 left from last time so I used them all up.


At this point I have replaced 5 Pi3B's with the new Pi3B+ models. I am now waiting for more heatsinks to arrive.

Setup is the same as before. For the first one I applied the latest set of updates to the Pi3B and shut it down. I removed it from its official Pi3 case and put the new 3B+ into the case. I swapped the SD card from the old one to the new one, plugged it in and off it went.

For the other four I decided I would get the latest Stretch-lite image, released 13 Mar 2018, and clean installed them.


After all the great photos above here is a link to a really professional video of the Pi3B+https://m.youtube.com/watch?feature=youtu.be&v=BRVT-JUn-vo