Do you have a lot of files lying around like photos, videos, documents, movies, music on your computer? Afraid that you 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.
Before we dive in, I’d also like to bring your attention to our recent article on NAS & RAID in edge server applications. It’ll greatly complement the content that is covered in this article, so be sure to check it out!
What is NAS?
NAS stands for network-attached storage, which allows you to store things like your movies, videos, pictures, etc on network-accessible external storage devices! This means you do not have to plug a USB storage directly into whatever device you are using whenever you want to store or access your files, 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 still want to get your hands on more storage after checking out these two solutions, keep a lookout near the end 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 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 be seamlessly integrated into active directory environments. Using Samba is one of the simplest ways to build a Raspberry Pi NAS as it is both easy to set up and configure!
What do you need?
- Raspberry Pi 4 Computer
- USB3.0 HUB 4 ports
- Cat6 Ethernet Cable – 1 Meter (For Gigabit Ethernet)
- 2 x External USB Drives (Minimum)
Step by Step Instructions
Step 1: Update your system
- First, you should make sure that you have an up to date version of Raspberry Pi OS. If not, you will need to download the Raspberry Pi Imager and follow the instructions to set up your operating system.
- If you are already running Raspberry Pi OS, 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 these 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 Shared 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:
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 Sharing Parameters
- 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 of the shared folder. For example, the shared folder will be created at the following address: \\raspberrypi\seeedstudioshare. You can rename it to whatever you like 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: If this option is set to yes, the folder will be writable.
create mask & directory mask: This option defines the permissions for the folder and the files it contains. By setting it to 0777, it will allow 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 and manage the Samba folder from Windows, macOS, or other Raspberry Pi devices
- 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:
And we are done! now we will just have to connect the Network attached storage on Windows or Mac OS.
Connecting to your Samba Server on Windows
Now we will connect to 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.
And you are done, you have just connected your windows to your Samba folder!
Connecting Samba Server on MAC OS
Now we will connect your Samba server on the MAC OS.
Step 1: Open Connect to Server Dialog
- First, 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.
- Once done, click connect to finalise the connection.
And you are done, you have just connected your MAC OS to your Samba share!
Building a Raspberry Pi 4 NAS with OMV (Open Media Vault)
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?
- Raspberry Pi 4 Computer
- 1 x External USB Driver
- micro SD Card with Card Reader-32GB(Class 10)
- Cat6 Ethernet Cable – 1 Meter
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 attached USB drives.
- 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 our OMV installation, we’ve 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?
If the basic Pi 4 setup is not sufficient for your storage needs, why not try some additional accessories to pimp your Pi out further?
- 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 note 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? Try this HAT instead!
- 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.
You don’t necessarily have to use the Raspberry Pi 4 for building a network attached storage. In fact, there are many solutions available on the market, including ones that use the Pi 4’s cousin, the Compute Module 4!
Compact & Ready-to-Use: PIzza for RPi CM4
The PIzza is a microserver powered by the Raspberry Pi Compute Module 4. It is designed for the easy setup and quick deployment for typical commercial and lightweight industry applications, including smart homes, 4G/LTE routers, digital signages and SD-WAN.
Furthermore, it can be used as a user-friendly mobile or portable OpenWRT VPN solution with the on-board dual gigabit ethernet ports. With the included NVME socket, you can easily use the PIzza as a Network-Attached Storage (NAS) or multimedia center in your home. You’ll be able to seamlessly access media files from multiple devices, or push them to the TV via HDMI at up to 4K resolution.
- Powered by the Powerful Raspberry Pi Computer Module 4 (CM4) @ 1.5GHz
- Diverse Wireless Connectivity Options
- Dual-Band Frequency 2.4GHz/5GHz WiFi
- Dual Gigabit Ethernet Ports
- 4G/LTE Communication via mini PCIe (Other modules supported)
- Expandable Storage: M.2 NVME Socket for SSD Expansion
- Multimedia Ready: HDMI Output at up to 4Kp60
- Integrated Thermal Management: Aluminium Heatsink with ABS Body
Interested to learn more? Learn more about the PIzza on the Seeed Online Store now!
If you’re building a NAS and want to take the opportunity to build up your network infrastructure as a whole, reServer is a complete edge server solution that can take care of virtually anything! Powered by the latest 11th Gen Intel Core Tiger Lake processors, reServer is a powerful choice for edge-to-cloud computing solutions. Furthermore, it comes with extensive connectivity, integrated cooling, and dual SATA hard drive bays for all your NAS needs!
- CPU: Latest 11th Gen Intel® Core™ i3 CPU running up to 4.10GHz
- Graphics: Intel UHD Graphics Xe G4 48EUs running up to 1.25 GHz
- Rich Peripherals: Dual 2.5-Gigabit Ethernet, USB 3.0 Type-A, USB 2.0 Type-A, HDMI and DP output
- Hybrid connectivity including 5G, LoRa, BLE and WiFi (Additional Modules required for 5G and LoRa)
- Dual SATA III 6.0 Gbps data connectors for 3.5” SATA hard disk drives with sufficient internal enclosure storage space
- M.2 B-Key/ M-Key/ E-Key for expandability with SSDs or 4G and 5G modules
- Compact server design, with an overall dimension of 124mm*132mm*233mm
- Quiet cooling fan with a large VC heat sink for excellent heat dissipation
- Easy to install, upgrade and maintain with ease of access to the internal components
Check out the reServer on the Seeed Online Store today!
Summary & More Resources
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! Alternatively, opt for an integrated solution like PIzza or reServer!
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!