How to build a Raspberry Pi 4 NAS Server? – Samba and OMV

Do you have a lot of files lying around like photos, videos, documents, movies, music on your hard drive? Afraid that they may run into drive failure? Want to build a network-attached storage (NAS) to prevent that but they are too expensive?

If your answer is yes to all the above questions, then this project is perfect for you! With the improved processing speed and performance of the Raspberry Pi 4 together with USB 3.0 and Gigabit Ethernet, you can build yourself a neat NAS Server at a cost-effective price.

What is NAS?

For those who do not know, NAS which stands for network-attached storage, allows you to store things like your movies, videos, pictures, etc on portable hard drives and external storage devices via your network! This means you do not have to plug a USB storage directly into whatever device you are using whenever you want to store something which is very convenient and perfect if you wish to back up multiple computers?

How do you do build a Raspberry Pi NAS?

Today, we are going to explore 2 solutions on how to build a Raspberry Pi NAS Server:

  • Building a Raspberry Pi 4 NAS with Samba
  • Building a Raspberry Pi 4 NAS with OMV (OpenMediaVault)

If you feel that isn’t enough storage for you, keep a lookout as we have a solution at the end to expand its storage capabilities!

Without further ado, let us jump right in on the first solution:


Building a Raspberry Pi 4 NAS with Samba

For the first solution, we will be using a software called Samba to build a NAS with Raspberry Pi.

Samba is a re-implementation of the SMB (Server Message Block) networking protocol that allows Linux computers to seamlessly integrate into active directory environments. Using Samba is one of the simplest ways to build a Raspberry Pi NAS as it is easy to set up and configure.

What do you need?

Step by Step Instructions

Step 1: Update your system

  • Firstly, you should already have a fully operating Raspbian system. If not, you will need to download Raspbian Buster Lite and follow the instructions to set up your operating system
  • If you have a running Raspbian system already, you will have to first make sure your system is up to date.
  • You can update the package list and all your packages by running this two commands:
sudo apt-get update
sudo apt-get upgrade

Step 2: Install Samba on our Raspberry Pi

  • After your Raspbian operating system is up to date, now we will have to install the Samba software on the Raspberry Pi.
  • To install the Samba packages, key in the following command:
sudo apt-get install samba samba-common-bin

Step 3: Creating a sharing folder

  • Now, we will have to create a place where you can store and share all of your stuff
  • This folder can be located anywhere, it is completely up to you. It can even on a mounted external hard drive.
  • For this tutorial, we will be creating a public and private folder that will be accessible on the NAS:
mkdir /home/pi/shared

Step 4: Sharing folder using Samba

  • Next, we will be sharing the above folder using Samba. To do this, you will have to modify the Samba configuration file.
  • Key in the following command to edit the file:
sudo nano /etc/samba/smb.conf
  • In addition, just below the authentication section of the file, paste this following line:
security = user

Step 5: Define Details of share

  • Within this file, add the following to the bottom. This text defines various details of share.
[seeedstudioshare]
path = /home/pi/shared
writeable=Yes
create mask=0777
directory mask=0777
public=no

[seeedstudioshare]: This defines the address and other configurations related to the shared folders. For example, the shared folder will be abe the following address: \\raspberrypi\seeedstudioshare. You can rename it to whatever you like to call your shared storage space as well.

path: This option contains the address of the directory that is going to be shared. If you wish to store the shared folder on an external drive, just change to path option here to point it towards your external drive.

writeable: With this option set to yes, the folder will be writable.

create mask & directory mask: This option defines the maximum permissions for both files and folder. By setting it to 0777, it allows users to read, write and execute.

public: This option is used to give permission to either give any user access to the folder or restricted access. With the option set to “no”, the Raspberry Pi needs a valid user to grant access to shared folders.

Step 6: Save changes

  • Now that we are done with the changes made to the file, we will now save it by pressing CTRL + X then Y and hit ENTER.

Step 7: Make a user for Samba on the Raspberry Pi

  • Next, we will make a user for our Samba server on the Raspberry Pi in order for us to make a connection to the shared network drive.
  • We will run a command to create a Samba user called “Pi”:
sudo smbpasswd -a pi
  • After running this command, you will be prompted to set a password that is up to you.
  • With this user “Pi” you can access the Samba share from Windows, macOS, or other Raspberry Pi devices with the ability to read and write files.
  • If you wish to create additional users, key in the following commands:
sudo adduser username
sudo smbpasswd -a username
  • Replace “username” with your choice of username.

Step 8: Retrieve Raspberry Pi local IP address

  • Lastly, we will have to retrieve our Raspberry Pi’s local IP address when connecting to Samba.
  • This is in the event the connection fails on your home network where we can still use the IP address to connect to the Samba Share
  • For this, make sure that you are connected to a network by either an ethernet cable or Wifi.
  • Key in the following command to get your Pi local IP address:
hostname -I

Annnnd we are done! now we will just have to connect the Network attached storage on Windows or Mac OS.

Connecting Samba Server on Windows

Now we will connect your Samba server on Windows.

Step 1: Go to Map Network Drive

  • To access files and folders on Windows system, we have to put the address of the shared media. You can do this by going My Computer and click Map Network Drive as shown below:

Step 2: Connect to the network folder

  • After clicking on Map network drive, this dialog will be shown.
  • You will have to fill in the address which you previously defined in step 5. For us it will be seeedstudioshare, please replace it accordingly to whichever name you have given it)
  • If the connection fails, switch out “raspberrypi” with your Raspberry Pi local IP address which you’ve got in step 8 previously.
  • Once you are done, click Finish to finalize the connection.

Step 3: Key in password

  • Lastly, you will be required to enter your login details to finish the connection.
  • Enter the username and password you created in step 7 and press ok.

Annnnnd you are done, you have just connected your windows to your Samba share!

Connecting Samba Server on MAC OS

Now we will connect your Samba server on the MAC OS.

Step 1: Open Connect to Server Dialog

  • Firstly, press Command + K to open the Connect to Server dialog where you will be able to key in the server address.

Step 2: Enter IP address and connect

  • Next, enter the details for your Raspberry Pi’s SMB share and the IP address.
  • You can do this by keying in smb://your_pi_ip_address/seeedstudioshare
  • Remember to swap out the name of the share if you changed it.
  • Once done, click connect to begin the connection to your Raspberry Pi’s Samba share.

Step 3: Enter Username and password

  • Lastly, before the connection is complete, you will prompted to enter the username and password that you have set up in step 7 earlier in this guide.
  • Once done, click connect to finalize the connection.

Annnnnd you are done, you have just connected your MAC OS to your Samba share!


Building a Raspberry Pi 4 NAS with OMV (OpenMediaVault)

The next option, we will use OMV (Open Media Vault) to build a Raspberry Pi NAS! This software has more advanced features, web configuration, and access but is slightly more complicated to use and install compared to Samba.

What do you need?

Step by Step Instructions

Step 1: Download OMV software

  • Firstly, we will have to download the OMV software for Raspberry Pi onto a PC.
  • Unlike Samba, which uses Raspbian, OMV has to be first downloaded as a disk image.

Step 2: Burn OMV image to microSD card

  • Next, use a program to burn the OMV image to the microSD card.
  • You can either use Etcher which is a easy drag and drop tool for burning image files or you can use Win32 Disk imager to burn the image.

Step 3: Connect everything to your Pi and power it up

  • Now, you will have to connect all the various peripherals to your Raspberry Pi (keyboard, mouse, display, power supply, ethernet cable) and also insert the microSD card with the OMV image.
  • You will also need to plug in all your external storage devices too and power it up.

Step 4: Set up OMV

  • After your Raspberry Pi is up and running, the Raspberry Pi will show a message on the screen with your Raspberry Pi IP address.
  • Open up a browser on your pc and navigate to the given address: http://your_OMV_ip_address/
  • You should see OMV landing page where you will required to login with a username and password.
  • The default login credentials for OMV are:
    • Username: admin
    • Password: openmediavault

Step 5: Mount your disks

  • On the left-hand menu of OMV, click on file systems under the storage heading and you will see your USB hardware drives that are attached.
  • Just select one of the devices and hit mount and then apply to add the drive.
  • And your device is mounted!

Step 6: Setting up Shared folders

  • Next, we will create shared folders to make your files available to multiple devices on your network.
  • To do that, go to shared folders under the Access Rights Management heading and click the add button to create a new folder.
  • Here, you will be able to name a folder, choose which storage device to store it in and also specify a path for it.
  • Remember to click save when you are done.

Step 7: Enable SMB / CFIS

  • Before shared folders are accessible to any devices, you will to enable SMB / CFIS which are sharing services.
  • You can find them under the services heading where on the left side navigation menu, select SMB / CIFS.
  • Select the enable option and select save and apply.
  • This brings SMB / CIFS online and the shared files will now appear on your network.

Step 8: Add users

  • Now, we will have to add users to OMV.
  • On the Access Rights and Management heading on the main left side navigation menu, click User.
  • Hit add to add a user. Here you can give your user a name and a password and click apply.
  • You can add multiple users to OMV where you can set different levels of permission for each here.

Step 9: Access your files

  • Lastly, to access your files, you can follow the instructions above on how to connect to the Samba server as they are the same!

For the OMV, we barely touched on its capabilities! Similar to many NAS servers, you can add data protection with RAID, mirror drives, etc. To get the most of OMV, you can check their wiki at OpenMediaVault Wiki!

Annnnd we are done! You have just set up a Raspberry Pi NAS using OMV.


Not enough storage?

Feel that this setup isn’t enough storage for your needs? Why not try Dual/Quad SATA HAT for Raspberry Pi 4 or Rock Pi 4 to design a 4-bay NAS!

Dual/Quad SATA HAT for Raspberry Pi 4 or Rock Pi 4

  • This is a Pi Hat for Raspberry Pi or Rock Pi 4 with SATA port which can insert HDD/SSD for extra storage. 
  • For 3.5inch HDD setups, a standard ATX PSU is required to power the HDD´s and the Raspberry Pi. With 4x 3.5inch HDD´s the PSU should provide at least 60W or more.
  • For 2.5inch HDD setups, the USB PD/QC power adapter ( >=30W power adapter ) is sufficient to power the disk drives and the Raspberry Pi 4 together. It is important to mention that the power connector on the SATA HAT must be used to power up the NAS with Raspberry Pi 4.
  • The Quad SATA HAT utilizes two high-performance JMS561 (one JMS561 for the Dual SATA HAT) and provides up to 400MB/s read/write performance with four disks in RAID0 mode.
  • You can see the Raspberry Pi 4 is connected to four 3.5″ SATA drives plus an external power supply (60W+ required), and Raspberry Pi 4 connected to 4 2.5″ drive plus the SATA HAT Top Board with fan, a power button, and an OLED display to show information such as  IP address and storage information in the previous 2 pictures.
  • To find out more, you can check out Radxa Wiki!

Use a Rock Pi 4 and want more storage?

Why not try this HAT for the Rock Pi 4!

Penta SATA HAT for Rock Pi 4

  • The Penta SATA HAT does not work on the Raspberry Pi 4 because it relies on the M.2/PCIe interface on ROCK Pi 4 to offer up 5x SATA ports which the Raspberry Pi 4 lacks.
  • With this HAT, it offers 4x SATA interfaces + 1x eSATAp for up to 100TB storage via 5 x 2.5″ or 3.5″ HDD / SDD!
  • To fully take advantage of the 5th SATA port, an eSATA connector was implemented which can be exported e.g. out of the case. The eSATA connector provides both data and power. It can directly drive a 3.5inch HDD via a single cable.
  • The Penta SATA HAT is powered by the JMB585 with 2 5Gbs PCIe buses with up to 10Gbps bandwidth. With 5 SSD’s configured in Raid0 mode, an archiving speed of up to 803MB/s can be achieved.

Summary

That’s all on How to build a Raspberry Pi NAS Server. What do you think of the two solutions, the Samba and OpenMediaVault? Which one do you prefer? Let us know in the comments down below!

If your NAS server has insufficient storage, we’ve always got you covered with the above SATA HATs to expand your Raspberry Pi 4 and Rock Pi 4 storage capabilities!

Interested in more Raspberry Pi 4 Projects? You can check out the Top 20 Raspberry Pi 4 Projects That You Must Try Now and also How to Build Your Own Raspberry Pi 4 Retro Game Console Using Retropie!

Please follow and like us:

2 thoughts on “How to build a Raspberry Pi 4 NAS Server? – Samba and OMV

  1. Does it really require the 4GB version?

    In order to save money, would the 1GB version be sufficient, given that the 4GB model is more than 50% more expensive than the 1GB model?

Comments are closed.

Wordpress Social Share Plugin powered by Ultimatelysocial