NAS on Raspberry Pi

This article is about setting up network storage on Raspbian (follow the link to view the article on my corporate blog)

1. What is a NAS Server

The core hardware components of a NAS storage system are media storage devices, primarily hard disks. When multiple storage devices are connected to a NAS server, you can organize them using a RAID controller (Redundant Array of Independent Disks) to create logical and redundant storage containers, ensuring enhanced data security and fault tolerance.

The following raid levels are present to help in safeguarding the data in the case where a disk has been lost.

The maximized operating system for the Raspberry Pi 2 and the Raspberry Pi 3 is Raspbian, a complimentary and open-source software predicated on Debian. Moreover, there are a couple of substitutive operating systems accessible for the Raspberry Pi.

This documentation is based on the most current “Raspbian Stretch” operating system, released on August 16th, 2017, and featuring kernel version 4.9.

3. Why NAS Server on Raspberry Pi

The Raspberry Pi is a small computer with the full-fledged work of the Linux operating system and possesses almost all the characteristics of a large server system.

Alternatively, the Raspberry Pi proves to be a budget-friendly option as it requires only a trifling amount of energy for operation. Its compact size grants it the versatility to be situated almost anywhere, making it an ideal solution for various applications and environments.

This all makes the Raspberry Pi an ideal candidate for your own small NAS storage system.

4. Alternatives NAS Server on Raspberry PI

Conversely, one can utilize preconfigured NAS storage server applications such as Openmediavault, Freenas, and nas4free to install on the Raspberry Pi, serving as an alternative to a custom-built Network Attached Storage (NAS) device. These software packages boast user-friendly installations and feature a web-based interface for configuring and managing storage and file sharing capabilities with other network users.

5. Setup a NAS Server on Raspberry PI

In this manual, we intend to establish a basic Network Attached Storage (NAS) server from the ground up, utilizing the Server Message Block (SMB) protocol. The objective is to store files on the NAS server and facilitate their sharing amongst various computer clients.

5.1 Requirements

To begin this project, you require a Raspberry Pi 2 or Pi 3 system with Raspbian installed and already connected to your network. Additionally, ensure you have either terminal access or have successfully logged in via a Secure Shell (SSH) connection to the Raspberry Pi.

For this project, we require an external USB-connected hard drive with a storage capacity of your preference.

5.2 Prepare your RaspPI

To commence the setup process, it is essential to verify that all packages are updated to their most current versions.

sudo apt-get update sudo apt-get upgrade

Assuming the Raspbian operating system is current, we can proceed with setting up our NAS server.

5.3 Install and Setup Samba Server

5.3.1 Create an internal share

The first step entails configuring directory sharing. Specifically, we will create a directory named “INTERNAL” within the home directory of the pi user. mkdir /home/pi/INTERNAL

Now open the /etc/samba/smb.conf file in an editor of your choice and enter the configuration options for the INTERNAL sharing at the end of the file, like shown below.


   comment = internal Files

   browseable = yes

   path = /home/pi/INTERNAL

   writeable = Yes

   create mask = 0777

   directory mask = 0777

   browseable = Yes

   public = yes

To access to the sharing, we need to allow the user pi to be a samba user.

sudo smbpasswd -a pi

You have to enter a password twice.

Restart the samba server.

sudo /etc/init.d/samba restart

5.3.2 Connect the internal share

We will now switch to a Windows 7 client and verify that the Samba server configuration is accurate, as well as confirm our access to the shared directory.

On the Windows system, navigate to the File Explorer, select “Map network drive” from the context menu, and proceed to configure the network drive mapping.

Within the dialog box, enter the IP address of your Raspberry Pi and the designated share name, “INTERNAL”, as illustrated below, to initiate the mapping process.

Note: Be sure you replace with your own IP address.

Now enter the username “pi” and the password we setup with the smbpasswd command.

Now we are connected to the Raspberry Pi, and we can save and share our files.

For testing, we create a directory “Directory” and inside this directory we create a “Document.rtf” file.

We go back to the Raspberry Pi, and inside our sharing directory, we will see the newly created files.

5.3.3 Prepare an external disk

To furnish a substantial amount of file storage, we can connect an external USB drive to the Raspberry Pi.

For this setup, we utilize a 1TB external USB storage device formatted with a NTFS file system to augment our storage capacity.

With the command lsblk we can check all connected devices.

As we can infer from the above diagram, the mmcblk0 at root is the SD card which comes with Raspbian operating system in two partitions. On the other hand, sda device is another detachable USB disk, which is connected to the Raspberry Pi in advance. Additionally, by using the diagram, it was observed that the sda device has a single partition, which is sda1 having a space of 931.

The sda1 partition contains a ntfs file system. To mount this file system, we need to install the ntfs-3g package.

sudo apt-get install ntfs-3g If it is done, we can mount the external disk to the new directory.

The last line you need to enter is presented below too, for automatic mount of the disks we have to make a change in the /etc/fstab file.

Now we have to reboot and check if the external disk was mounted automatically.

As you can see above, the external disk partition /dev/sda1 is already mounted to the /EXTERNAL mount point.

For testing purposes, we create a directory and a file inside the / EXTERNAL directory.

5.3.4 Create an external share

Now we are ready to share the external disk to the network. For that, we have to add the following configuration part to the end of /etc/samba/smb.conf file.


   comment =  external Files

   browseable = yes

   path = /EXTERNAL

   writeable = Yes

   create mask = 0777

   directory mask = 0777

   browseable = Yes

   public = yes

Restart the samba server. sudo /etc/init.d/samba restart

5.3.5 Connect the external share

Now we move over to a Windows 7 client to check if the external share is also available in the network.

As described in Section 5.3.2, we map the external sharing on the same way, with the EXTERNAL instead of INTERNAL sharing name.

Now we can see the external sharing directory with the test file external.file inside.

5. Final notice

Pros and Cons of the NAS on Raspberry PI:

Also, it is pertinent to notice that with the help of ExaGear Desktop one can run most of the x86 applications on any ARM devices starting from Raspberry Pi, Odroid, Banana Pi, Beagleboard, Cubox, Jetson, Cubieboard, and etc.

Source: NAS on Raspberry Pi

About The Author

Muhammad Bilal

I am highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Scroll to Top