Introduction: Raspberry Pi NFS and Samba File Server
This project is the final stage of outcome which integrating two previously made and posted circuits.
1. Raspberry Pi CPU Temperature Indicator - Published Nov 20th, 2020
2. Raspberry Pi Box of Cooling FAN With CPU Temperature Indicator - Published Nov 21st, 2020
Originally I planned to make file server which can share files among RPI (Raspberry Pi), Windows PC and other Linux servers.
To avoid inconvenience of copy something to USB from source machine and re-copying everything to target machine again, RPI based Samba and NFS server can be utilized as file server.
Although scp or rsync command can be utilized between Linux machines (e.g. Ubuntu and Raspberry pi OS servers), using common file handling command such as cp and mv is much more convenient.
Therefore, RPI file server shown in the picture above is made.
This server can support the following functionalities.
- SSD (SanDisk, black one in the picture above) support NFS for file sharing between Linux servers
- HDD (Seagate, white one) support Samba for sharing files between my Windows PC and RPI
- Internal dedicated RPI power supply (5V 3A) is used
- RPI CPU temperature indicator (4 temperature levels) is integrated
- Cooling FAN automatically activating when temperature is higher than 50C
Let’s look more detail how file server is assembled and configured.
Step 1: File Server Design and Components
As file server is constructed by assembling circuit boards and other components such as HDD, SSD, switch power module and so on, I’m only showing overall structural diagram.
Regarding circuit details of cooling FAN and CPU temperature indicator, please refer previously posted contents of the projects.
I’ll explain only newly added components to make file server.
- Seagate HDD is 2.5” DATA disk which I bought quite long time ago (maybe 10 more years) and it including SATA to USB interface adaptor (Metallic chassis is removed)
- SanDisk SSD is interfaced with purchased SATA to USB3.0 adaptor which I bought from internet store (You can search this item by name of “SATA to USB cable”)
- Small 15W AC-DC switching power supply (Mean Well RS-15-5)
- Acrylic chassis (Transparent panel size is 15cm(W) x 10cm(H) x 5mm(D) x 1, 15cm(W) x 10cm(H) x 3mm(D) x 3
- Metal supporter 7cm (3.5mm) x 4, 4cm (3.5mm) x 4, 3.5cm(3.5mm) x 4
- Bolts and nuts
Except above new components, all other items are reused as outputs of previous projects including PCB boards, connectors and cables.
Step 2: Installing Switching Power Module
As you handling and connect to high voltage (220V) house power, careful wiring is absolutely necessary for this work!
Please check product documentation carefully to connect power module to RPI.
As RPI 3 Model B requires minimum 2.5A PSU (Power Supply Unit) as recommendation, I using 3A dedicated switching power supply.
Also to prevent under voltage warning of RPI, I’m slightly adjust output voltage as 5.3V by turning VR of switching power module.
When two external hard disks are attached, usually output voltage of switching power is slightly decreased and the under voltage warning of RPI (Yellow thunder bolt icon) is often observed.
In case of RPI 3 Model B, maximum total USB peripheral current draw can be supported up to 1.2A.
Therefore, driving two external hard disks will not be problem.
But when cooling and other circuits are operating, they will draw at least about more than 300mA current.
Therefore, I’m using additional hand-phone charger for powering other circuits and FAN.
According to the RPI specification, normally 500mA is drawn even in mild system load.
Because I had some troubles with RPI power before, supposedly complete power supply line separation seems the clearest solution.
Step 3: Completing Basic RPI Box
When you are not necessary no additional peripherals connection, this is the completely equipped RPI box including internal power supply and temperature regulation.
But as I’m making file server, external hard disk will be mounted to this basic RPI box chassis.
For housing circuit board and components, commonly I’m using acrylic panels and metal supporters.
I’m suppose it’s the easiest method to assemble everything into a single integrated enclosure like structure.
Step 4: Assembling and Mounting HDD
Actually when everything is put together and housed into acrylic chassis, usually I don’t want to de-assemble it as cables are always make headaches.
But HDD need to be mounted and fixed, I had de-assembled and you can see how circuit boards are packed together inside the acrylic chassis.
Acrylic panel has advantage of easy layer addition by simply stacking another panel on the top of existing one.
Due to this feature, I’m using acrylic panel in the most of DIY projects.
Step 5: HDD Mounting and Fixing
Stacking second layer which housing Seagate HDD is completed and connected with RPI via USB cable.
For mounting additional acrylic panel on top of existing one, drilling is necessary to make 4 holes to which metal supporters are inserted.
Aligning holes location is necessary for assembling acrylic panels as nicely stacked manner.
Step 6: Mounting and Connecting SSD
As last stage of assembling works, SSD is mounted on additional acrylic panel and fixed on the top of second layer with metal supporter.
When 4 hole locations is not correctly aligned to each other in every panel layers, assembling work become a little bit difficult and finished chassis shape become a little bit ugly.
Step 8: Installing and Configuring Samba
As very detail how-to and technical descriptions are abundant in diverse websites, I will not explain detail about Samba itself and nitty-gritty of install procedure.
Summarize everything and only mentioning highlights of Samba installation and configuration as follows.
- sudo apt install samba samba-common-bin (Install samba)
- sudo smbpasswd -a pi (Add pi as Samba user)
- sudo vi /etc/samba/smb.con (Insert the following configuration data to smb.cnf)
comment = pi shared folder
path = /mnt/nashdd
valid users = pi
browseable = yes
guest ok = no
read only = no
create mask = 0777
- sudo /etc/init.d/samba restart (Restart Samba service)
When installation and configuration is completed, you can mount RPI directory “/mnt/nashdd” (actually it’s 500GB of whole disk volume of Seagate HDD) as Network drive as shown in the picture above.
Samba is very useful tool for uploading/download of files from Windows PC and RPI.
The temperature fluctuation graph shown in the step below is created by copying log file in RPI to Windows PC via Samba.
Step 9: Installing and Configuring NFS
When NFS client mount shared directory, “df
-h” command output of client shows mounted NFS volume as shown in the picture above.
NFS installation and configuration is quite complex than that of Samba.
Therefore, I’ will not explain details about how to install NFS to server and client.
Also configuration requires editing several files such as “/etc/fstab”, “/etc/exports”, “/etc/hosts.allow” and so on.
You can find detail how-to and technical explanation at the following website.
I’m using NFS frequently for harvesting downloaded files from torrent server without using complex scp or rsync commands.
Simple you can cp or mv files like they are stored in the local disk.
Also as you can see in the final “Further development” step of this story, some more useful application can be possible.
Step 10: Temperature Control
I’m just curious how cooling FAN circuit control CPU temperature over the almost one day period.
So I copied log file via Samba file sharing service and making graph with MS excel.
The results are as follows.
- After operation of cooling FAN circuit, temperature never exceeding 50C
- Several times more than 50C is observed, still temperature decreased immediately due to the cooling FAN operation
- NFS write (moving downloaded video files from torrent server to NFS server) make significant system load to NFS server
- Temperature raising quickly and cooled down subsequently due to the running of cooling FAN
- NFS read (Playing video from NFS server by client with VLC) system load is not much significant as you can see later stage of graph
Step 11: Further Development
As all relevant hardware related works are completed, no additional modification or development will be made to NFS/Samba file server.
But NFS server can be utilized as various manners as shown in the picture above.
Among two putty sessions, left side is NFS server’s screen and right side is VLC client application running client screen.
Played vide is shown in the 5 inch LCD above the PC screen.
As I mentioned, this kind of NFS server access and utilization does not burdening server too much.
Thank you for reading this story to end….