Setup NAS Server on Raspberry Pi 3

29/12/2020
NAS servers are really costly these days. If you don’t have that much money to spare, then you use Raspberry Pi 3 to set up a low cost NAS server very easily.  In this article, I will show you how to set up a low cost NAS server using a Raspberry Pi 3. I will use Raspberry Pi 3 Model B for the demonstration in this article. But any model of Raspberry Pi 3 should work just fine. So, let’s get started.


To build a low cost NAS server with Raspberry Pi 3, all you need is:

  • A USB hard drive dock and a SATA 2.5” or 3.5” hard drive. You can also use a USB thumb drive for storage. It’s up to you.
  • A Raspberry Pi 3 Model B or Raspberry Pi 3 Model B+.
  • A microSD card with Raspbian OS flashed. I have a dedicated article on installing Raspbian on Raspberry Pi. You can check it out at LinuxHint.com.
  • An Ethernet cable.
  • An Android Phone charger for powering up Raspberry Pi 3.

Connecting to Raspberry Pi Remotely:

Now, connect all the required components such as USB thumb drive or USB self-powered hard drive (using a USB hard drive dock), microSD card with Raspbian OS image flashed, Ethernet cable, and micro USB power cable. Finally, power on your Raspberry Pi. Now, connect to your Raspberry Pi via SSH or VNC depending on your preference.

NOTE: Use the username pi and the password that you set while configuring Raspbian for the first time. If you’ve configured Raspberry Pi headless, then the default password is raspberry.

To connect to your Raspberry Pi via SSH, use GitBash or PuTTY. Both of them are free to download and use.  To connect to your Raspberry Pi via VNC, use VNC Viewer from RealVNC. It is free to download and use. Once you’re connected, you are ready to move on to the next section.

Installing Samba on Raspberry Pi:

In this article, I will use Samba on Raspberry Pi for file sharing. It allows file sharing using Windows SMB or CIFS protocol. Windows has native support for Samba shares.  Samba is available in the official package repository of Raspberry Pi. So, it is very easy to use. First, open up a Terminal and update the APT package repository cache with the following command:

$ sudo apt update

Now, install Samba with the following command:

$ sudo apt install samba

Now, press y and then press <Enter> to continue.

Samba should be installed.

Mounting Storage Devices:

Now that Samba is installed, it’s time to mount the USB thumb drive or USB hard drive on your Raspberry Pi. First, connect your USB thumb drive or USB hard drive on Raspberry Pi.

Usually, it will be available in /dev/sda1.

If you’re unsure, you can find out what it is for you with the following command:

$ lsblk

As you can see, the block device is sda and the partition is sda1 in my case. So, the partition can be accessed as /dev/sda1.

Now, create a directory (let’s call it Media) where you want to mount the USB thumb drive or hard drive with the following command:

$ sudo mkdir /mnt/Media

Now, edit /etc/fstab file with the following command:

$ sudo nano /etc/fstab

Now add the line as marked in the screenshot below at the end of the /etc/fstab file. Once you’re done, save the file with <Ctrl> + x and then press y followed by <Enter>.

NOTE: Here, ext4 is the filesystem format of the USB thumb drive or hard drive you want to mount. It may be different for you. Make sure you put the right filesystem type here.

Now, mount the partition /dev/sda1 to /mnt/Media mount point with the following command:

$ sudo mount /mnt/Media

Your USB thumb drive or hard drive should be mounted in the /mnt/Media mount point as you can see in the screenshot below.

$ df -h

Now, change the owner of the /mnt/Media mount point to pi with the following command:

$ sudo chown -Rf pi:pi /mnt/Media

Configuring Samba Share:

Now, edit the Samba configuration file /etc/samba/smb.conf with the following command:

$ sudo nano /etc/sambab/smb.conf

The /etc/samba/smb.conf configuration file should be opened. Now, at the end of the configuration file, type in the lines as marked in the screenshot below. Once, you’re done, save the file.

Now, run the following command to make your existing pi user a Samba user and set a password for the Samba user:

$ sudo smbpasswd -a pi

Now, type in a Samba password and press <Enter>.

Retype the same password and press <Enter>.

A Samba user pi should be added.

Finally, restart your Raspberry Pi with the following command:

$ sudo reboot

Connecting to the Raspberry Pi NAS Server:

Now that you’ve successfully configure the Raspberry Pi NAS server, you can connect to it from your Windows computer and any other devices that has support for SMB/CIFS protocol. First, check the IP address of your NAS server. It is the same as the IP address of your Raspberry Pi. If you remember it, skip to the next instruction.

$ ip a

Now, from your Windows computer, click on Computer tab and then click on Map network drive as marked in the screenshot below.

Now, type in the NAS Folder address, make sure Connect using different credentials is checked. Then, click on Finish.

Now, type in the username pi and the Samba password that you set a little while ago for the user pi. Then, click on OK.

Your NAS storage should be mounted as you can see in the screenshot below.

As you can see, I can copy files to the NAS.

So, that’s how you create a cheap NAS server with Raspberry Pi. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Các ứng dụng sử dụng proxy như thế nào để bảo vệ địa chỉ IP của bạn.

Trong thế giới của công nghệ thông tin hiện đại, Proxy đã trở thành một công cụ không thể thiếu...
27/02/2023

How to Install Zabbix on Raspberry Pi 3

Zabbix is an open source software for monitoring servers, cloud services, virtual machines and many more. In this article,...
29/12/2020

Hướng dẫn cài đặt LAMP stack trên Ubuntu 20.04 LTS

LAMP (viết tắt của Linux – Apache – Mysql database hoặc MariaDB – PHP.) là một hệ thống...
30/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Reliable IPv4 and IPv6 Subnet Rental Services: The Perfect Solution for Global Businesses
23/12/2024

Tìm Hiểu Về Thuê Proxy US – Lợi Ích và Cách Sử Dụng Hiệu Quả
11/12/2024

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024