Turn your Raspberry Pi into a NAS using Samba (SMB) Server

Here's a good beginner's Raspberry Pi project where you can turn your Pi into NAS using SMB server.
Warp Terminal

Are you tired of the challenge posed by a crowded local storage, making file retrieval feel like a scavenger hunt?

Worry not! Today, we embark on the transformation of your Raspberry Pi into a Network-Attached Storage (NAS) solution.

Say farewell to the complexities of an overloaded local storage. Instead, envision your Raspberry Pi, equipped with a Samba Server, seamlessly organizing files for efficient collaboration, simultaneous access, and reliable backups.

What is Samba?

Samba is a software suite that enables seamless file and print services interoperability using Server Message Block (SMB) / Common Internet File System (CIFS) file sharing standard which is widely supported by various operating systems like Windows, MacOS, Linux and even Android.

There are other NAS oriented solutions available for Raspberry Pi like Open Media Vault. I find SMB share to be the easiest to set up and if you are new to network storage, I think you should try this hassle-free method.


  • Raspberry Pi
  • SD Card (8 GB+)
  • Raspbian OS installed (commands mentioned here work on that)
  • Ethernet Cable (Optional)
  • Keyboard & Mouse (Optional)
  • External HDD/ SSD
The USB ports on Raspberry Pi may not be sufficient enough to power up an External Hard Drive. So, I would suggest you to use an external power supply or buy a HDD docking station.

Installing Samba and it's dependencies

First, make sure to install Raspbian OS on your Raspberry Pi. I won't discuss those steps here.

The first order of business when start working on Linux is to ensure that you have all the latest packages installed.

sudo apt update && sudo apt upgrade -y

To install the Samba packages you just need to apt-get as they are available in the repository.

sudo apt-get install samba samba-common-bin

The work is not done here since you need to create a folder which will be shared. This folder can be located even on external drive mounted to Pi.

Creating a shared folder

For this tutorial, I am mounting an external drive and creating a new folder inside /media directory.

I am going to give this folder all the permission i.e. read/write/execute (rwx) so that anyone on my sub-network with the access to my server can share files easily.

sudo mkdir -m 1777 /media/hdd/shared

Editing the SMB Config file

Once you have created the folder, it's time to configure your SMB share. You need to do is edit smb.conf file to make your share visible on the network.

sudo nano /etc/samba/smb.conf

Inside this config file, you need to add the following code at the bottom:

path = /media/hdd/shared
create mask=0777
directory mask=0777

Then save and exit out of Nano using CTRL + X then press Y .

Here, [itsfossnas] is the name of my share and it'll be used to connect to the network share with the address like \\localhost\itsfossnas.

Editing samba config file

Creating a User for Samba share

Creating a user for Samba share is crucial for access control, security, and personalized settings.

I am going to create a user called abhishek in this example.

sudo smbpasswd -a abhishek

Once you press Enter, it will prompt you to create a password for this user.

Create Samba user

Finally, you need to restart the samba service:

sudo systemctl restart smbd

Samba will restart automatically when every time you boot up your Pi.

Now it's time to connect to your Samba share and to do that, you need to locate the Pi on the network.

The easiest method is to type hostname -I on the terminal or you can check the DHCP record of your router which will show the IP address assigned to your Pi.

Mounting your Samba Server on Windows

To mount your server in Windows is quite simple. Inside the file explorer app, at the top you will need to click the menu icon ... and a list of options will pop up on your screen from which, You have to select Map Network drive .

I am using Windows 11 in this tutorial.

Mount NAS on Windows

After that, it will ask you to set the drive letter for your share and the address of your Server. In my case, it is \\\itsfossnas .

Mount NAS on Windows

Finally, it will prompt you to enter you Login credentials i.e. the Username and the Password we set at the above step and once you are done, just press Ok.

Mount NAS on Windows

Your drive is now mounted successfully.

NAS mounted on Windows

The speeds will vary based on whether you are on WiFi or connected via Ethernet cable.


I won't say that this will be your permanent storage and backup solution but it is quite impressive that how such a small device can do so much.

I think it's great for learning about Network Storage options before you go all in and buy an expensive NAS.

Hope you have learned something new. Feel free to share your experience or your DIY storage solutions with us in the comments.

About the author
Abhishek Kumar

Abhishek Kumar

I'm definitely not a nerd, perhaps a geek who likes to tinker around with whatever tech I get my hands on. Figuring things out on my own gives me joy. BTW, I don'tΒ useΒ Arch.

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world


Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.