Recently I have joined a company as WordPress Theme Developer. In the company, whenever we need to share files, we share it via Google Drive or Slack. The main problem in this process is whenever we need some files, we have to request the particular user for files and then he/she has to upload it. This process is time-consuming and even problematic to remember the upload files link whenever required in future. This process is simply more time consuming and a waste of resources. So I came up with an idea to setup NAS server using Raspberry Pi in the company to facilitate easier sharing of files among the employees.

NAS stands for Network Attached Storage. In this article, I will explain in detail to setup NAS server using Raspberry Pi. With this process, you can even set up your own NAS server for your home where you can share files in your WiFi network among your family and friends.

To setup NAS server using Raspberry Pi, you need to have the following things:

  • Raspberry Pi ( Model 2 or 3B will work fine. I have used Model 3B as it offers high speed)
  • SD Card – 8GB or 16GB
  • Ethernet cable
  • External Harddrive ( I am using WD Slim 1TB External drive)
  • Power cable
  • High-Speed Internet Connection
  • Monitor (optional)
  • Keyboard (required if using Monitor)

If you don’t have a monitor, don’t worry I will guide you to set up using your Laptop or PC.

By the end of this article, you will be able to do the following things on your own:

  • Create your own Local NAS Server
  • Install Raspbian Stretch Lite OS on your Raspberry Pi via SD card
  • Access Raspberry Pi using command prompt or terminal via SSH
  • Share files and folders in your network
  • Create user profiles to allow specific users only
  • Setup automatic mounting of external drive whenever Raspberry Pi reboots
  • Access your External Hard Drive files on NAS server

Now, let us dive into to setup NAS server using Raspberry Pi.

Software Installation and Initial Setup

To install the Raspbian Stretch Lite OS, you need to download followings things:

All these software are free to download. Go ahead and download and install this software. Once the download and software installation is finished, do the followings:

  1. Extract Raspbian Stretch Lite OS image file using Winrar or 7zip.
  2. Insert your SD card and launch SD Card Formatter software and Format it.
  3. Open Win32DiskImager, locate the extracted image file of Raspbian Stretch Lite OS by clicking on the folder icon. Make sure under Device, you have selected the SD Card drive which in my case is E: drive. After doing so, just click on Write button.
    How to setup NAS server using Raspberry Pi? 1

It will take a couple of minutes to finish writing files to SD card. Once it is done, we need to perform one more operation i.e enable SSH to access it via command prompt or terminal.

Also read : How to Transfer Files from PC to Phone using WiFi?

Steps to Enable SSH using Command Prompt or Terminal

It is very easy to enable SSH in just two following simple steps:

  1. Open your Command Prompt or Terminal as an administrator.
  2. Type the following commands:
    echo>E:\ssh  – in Windows (where E: is my drive letter)

For Linux users, you can navigate to SD card drive path in your terminal and create the file by  typing the following command: echo>ssh or cat>ssh

It will create an ssh file which will activate ssh protocol and we will be able to access a raspberry pi in Command Prompt or terminal.

Once that is done, safely eject the SD card and plug it in Raspberry Pi. Then connect Ethernet cable, External Harddrive, and Power cable. If you connect your Monitor using HDMI cable, you will also have to connect a keyboard and skip the part of Accessing Raspberry Pi with SSH. When the power plug is connected, it will start booting up the Raspbian Stretch Lite OS.

Accessing Raspberry Pi in Command Prompt

If you are using a monitor, then skip this part and dive into another section below. In order to know the IP address of your Raspberry Pi, launch Wireless Network Watcher and click on the play button(green colored). It will scan your network and show devices connected to your network. You will also get the IP address of your Raspberry Pi. In my case, the IP is

Now launch Command Prompt as administrator and type the following command: ssh [email protected] (here pi is username)

How to setup NAS server using Raspberry Pi? 2

You will be asked whether you want to continue connecting. type Y, hit Enter and then type yes and again hit Enter.

Now type the password which by default is raspberry and hit Enter. Now you are in the raspberry terminal.

If you are using a monitor, you will be asked to enter username and password. By default username and password are pi and raspberry respectively. Once you enter it, you will be in raspberry terminal.

Steps to Setup NAS server using Raspberry Pi

Once you are in the raspberry pi terminal, first you need to update the existing repos. Type the following command:

sudo apt-get update

Now the update of repos is finished, you need to install support for NTFS filesystem as your hard drive will have an NTFS filesystem. Type the following command to install NTFS filesystem support:

sudo apt-get install ntfs-3g

How to setup NAS server using Raspberry Pi? 3

Now, to setup NAS server using Raspberry Pi, we need to install Samba Tools and configure it.

Installing and Configuring Samba Tools for NAS server

In order to install Samba tools, type the following command and hit Enter:

sudo apt-get install samba samba-common-bin

How to setup NAS server using Raspberry Pi? 4

It will ask permission to install it, type ‘Y‘ or ‘yes‘ and it will start downloading and installing samba tools. Since I have already installed it, it didn’t ask any permission.

Now you need to create a folder where you will mount your external hard drive. In my case, I will go by the name External. You can name is whatever you like. To create a folder, type the following command and hit Enter:

ls /External

Now when you type: ‘ls /‘ command you will be able to see all the files and folders.

How to setup NAS server using Raspberry Pi? 5

As you can see, there is a folder called External which you will use to mount your external hard drive.

Now, type the following command to see all the connected device and hit Enter:


As you can see in the highlighted section, it has detected the external hard drive and it is currently unmounted. In order to mount the drive to External folder what you just created, type the following command :

sudo mount /dev/sda1 /External

How to setup NAS server using Raspberry Pi? 6

(where ‘/dev/sda1‘ is a path of my external drive, replace it if it’s different than mine)

In my case, it was successfully mounted without any errors as you can see in the picture above. If it throws any errors, then execute this command :

sudo ntfsfix /dev/sda1

(again ‘/dev/sda1‘ is a path of my external drive, if it’s different replace it with yours and reboot the system and type the above command to mount it)

Since the mounting was successfully completed, if you type the ‘lsblk‘ command, you will be able to see that the External Hard drive has been mounted to an External folder which you created earlier.

Now, in order to setup Samba server, you need to configure Samba config file. To do so, type this command to configure Samba server:

sudo nano /etc/samba/smb.conf

How to setup NAS server using Raspberry Pi? 7

You will see something like this in your terminal as shown above. Now press down arrow key and scroll till the bottom of this file where you will need to add the following lines exactly:

comment = Pi NAS Server
writable = yes
browseable = yes
path = /External
create mask = 0777
directory mask = 0777
public = yes
guest ok = no
valid users = nabinjaiswal raushan

Let me walk you through these:

  • [RaspberryPiServer] : It is the name of the server. You can rename it whatever you like.
  • comment : It is a comment for your server, more like a description type.
  • writable : To allow users to add files or not. If you don’t want them to write files, then type writable = no
  • browseable : Allowing the users to browse through the files.
  • path : Path to the mounted Folder
  • create mask and directory mask : for security and permission purposes
  • public : To make it visible publicly across your network
  • guest ok : Disabling guest access
  • valid users : add users here to give them access to this server. You need to add these users in the database and store their information. In my case, I have allowed two users: nabinjaiswal and raushan

Now you have added those lines, press Ctrl+O and hit Enter on your keyboard to save the changes to the file. Finally, press Ctrl+X to exit from file editor.

Also read: How to Manage Multiple Accounts at One Convenient Place?

Creating User Profiles

I will show you to add one user and you can repeat the same process to add other users. To add the user, type the following command :

sudo adduser username

How to setup NAS server using Raspberry Pi? 8

(e.g sudo adduser nabinjaiswal)

It will ask you to enter a password twice which by default is raspberry, enter it. Then you get options to add Full Name, Room Number, Work Phone, Home Phone and Other. Enter the relevant information and press Enter or just press Enter to skip. At the end you will be asked whether the information you mentioned is correct or not, simply type ‘y‘ and hit Enter on your keyboard.

Now,  you need to set the samba password for the newly created user. Type this command :

sudo smbpassd -a username

How to setup NAS server using Raspberry Pi? 9

(e.g sudo smbpasswd -a nabinjaiswal) .  Add the password and your user will be created. Here’s the screenshot of it:

Just repeat the above commands to add more users. Before we dive into how to access your files over a network, you need to do one last thing.

Enabling Auto Mounting of External Hard Drive

If you don’t do this step, you need to mount your external hard drive every time your system boots up. So it’s better to enable auto mounting of your external hard drive.

To do so, type the following command:

sudo nano /etc/fstab 

and add the following lines at the bottom:

/dev/sda1 /External auto defaults, user 0 2

How to setup NAS server using Raspberry Pi? 10

Press Ctrl+O, hit Enter to save the changes and press Ctrl+X to exit the editor.

Restarting Samba Server

Since all the changes have been done, you need to restart Samba server to implement the changes. To restart the samba server, execute the following command:

sudo /etc/init.d/samba restart

How to setup NAS server using Raspberry Pi? 11

Now everything is set up and you can access your files and folder over your network. I will illustrate how you can access your server in Windows PC and Android app.

Accessing NAS Server in Windows PC

In order to access your NAS server, you need to turn on your Network discovery. You can enable Network Discovery, via Control Panel > Network and Sharing Center > Change advanced sharing settings. Under Private > Network Discovery, select ‘Turn on network discovery‘  and save the changes.

How to setup NAS server using Raspberry Pi? 12

Now you have done it, you can easily access your server files with your credentials. Open your This PC and click on Network icon located at the bottom left corner. You will see RASPBERRYPI there.

How to setup NAS server using Raspberry Pi? 13

Double click on that folder, you will see your RaspberryPiServer folder. To access the files, double click on it and you will prompt to enter your credentials. Just enter the username and password you created earlier and you will be logged in the server.

How to setup NAS server using Raspberry Pi? 14

Once, you enter the credentials correctly, you will be able to see all files and folders located in the drive as shown below:

How to setup NAS server using Raspberry Pi? 15

Since you have given writable permission earlier in smb.conf file, you will be able to add files and folders in this server. When I added files, I got a decent speed roughly about 10MBps to 15MBps.

In case if you want to access files as different users, you need to first log out and then again enter the credentials. To log out of your shared network, open Command Prompt and enter the following command:

net use * /delete

How to setup NAS server using Raspberry Pi? 16

This command will log you out and you will be able to access the network again with different credentials.

Accessing NAS Server in Android Device

In an android device, you can easily access your NAS network with File Manager app. Here’s the download link. Once the download is finished, launch the app. You will see similar User Interface. Click on Remote icon.

How to setup NAS server using Raspberry Pi? 17


There you will see  ‘+Add a remote location‘ tab. Tap on that and select Local Network. Inside your local network, you will see your NAS Server and PC folders as shown below:

How to setup NAS server using Raspberry Pi? 18

Tap on RASPBERRYPI (or whatever your server name is). Now you need to enter your login credentials. Once you entered correct login credentials, you will see your RaspberryPiServer folder. Navigate inside the folder and all your files and folders stored in External Hard drive will be listed.

Wrapping Up

The possibilities are endless and you can create more complex NAS server by editing smb.conf file. Here’s a link to Samba official website where you can learn in depth. I know this article has been quite long but I have tried to explain in details and walk you through setting up your NAS server from a beginners perspective. If you have successfully come to this far, congratulations! If you faced any issues to setup NAS server using Raspberry Pi, do let me know the issues in the comment section below.


Facebook Comments

You may also like..

Popular Posts

Leave a Reply

Your email address will not be published. Required fields are marked *