In this tutorial we’re going to cover two great ways to create a Raspberry Pi NAS for your home (or office)! It’s a great way to store media files, photos, personal documents, and more. It’s also a good idea to have a place to keep backup copies of items stored on your home PC or laptop. A Raspberry Pi NAS is affordable and simple to setup!
We’re going to cover two ways to create a Raspberry Pi NAS in this article. Samba and Open Media Vault. Both get the job done, but in very different ways. Let’s start with Samba!
Preparing to Install Samba or OMV
As with all of our tutorials, we highly recommend you update your Raspberry Pi to the latest version. We keep our tutorials up-to-date with the latest changes, and hence the most common complaints we hear are fixed by simply updating Raspbian before you begin. To update Raspbian to the latest version, run the following commands:
sudo apt update sudo apt upgrade
Once updates finish, we highly recommend you reboot your Raspberry Pi to make sure everything is fresh (use the sudo reboot command).
Parts list for this project:
OPTION 1: Build a Raspberry Pi NAS with Samba
The first and simplest way to build a Raspberry Pi NAS is to use the built-in Samba service provided by Raspbian. Samba has been around for decades and is a great way to create simple file shares that can be accessed remotely by Windows, Linux, or even MacOS. If you’d rather use OMV, you can skip about halfway down this article.
Let’s first create a place to store all of our shares. Execute the following commands:
sudo mkdir /home/MyShares sudo mkdir /home/MyShares/Public sudo chown -R root:users /home/MyShares/public sudo chmod -R ug=rwx, o=rx /home/MyShares/public
These commands create a home folder called MyShares and gives read/write access to users of the Raspberry Pi. Don’t worry, if you want to add an external hard drive we will cover that a little further down.
Now we need to add and configure the Samba software for our Raspberry Pi NAS! This just requires some quick installations and just a bit of configuration. Let’s start by installing Samba and its base utilities:
sudo apt install samba samba-common-bin
Next we need to edit the Samba configuration file to make everything work. Issue the following command:
sudo nano /etc/samba/smb.conf
Just below the Authentication section add the following line:
security = user
Now let’s tell Samba about the shared folders we created earlier and set some basic permissions around them. At the bottom of the file add the following lines:
[public] comment = public storage path = /home/MyShares/public valid users = @users force group = users create mask = 0660 directory mask = 0771 read only = no
Close the file and save it by pressing Control+X and then answering Y to save. This completes our configuration of Samba! We just need to restart the server in order to make it all take effect. Issue the following command to restart Samba:
sudo /etc/init.d/samba restart
All that’s left to do now is to add the “pi” user to Samba. Enter the following command:
sudo smbpasswd -a pi
You will be prompted to enter and verify the password for this user. Once you do that, you’re ready to access your shares!
Connecting to the Raspberry Pi Samba Server
Your Raspbery Pi NAS based on Samba is now up and running. To connect to it you only need to open a file explorer on your computer and browse the network. You’ll see your Raspberry Pi and its shared folder waiting to be accessed!
If for some reason the Pi isn’t showing up enter \\your_pi_ip_address\public into the my computer. In my case \\192.168.1.44\public.
If you don’t know the IP address of your Raspberry Pi you can find it by entering hostname -I at the command line.
You can also map the network drive to make it a permanent drive letter on your computer.
Connecting on a Mac
If you’re using a Mac, you can connect to your Samba share by pressing Command+K and then entering smb://your_pi_ip_address/public into the connection box and clicking connect.
Adding an External Hard Disk to Your Raspberry Pi Samba Server
Of course, the MicroSD card on your Raspberry Pi is probably pretty small and you’ll likely want to add some additional space. Especially if you need to store a bunch of multimedia files like Movies and TV shows. All you’ll need is a USB Hard Drive of your preferred size to get started.
After the hard drive is connected to your Raspberry Pi, wait a few seconds for it to be recognized and then enter the following command:
This command will list the latest information on the USB bus and should include the name of the recently attached hard disk. In our case the new device is SDA1.
umount /dev/sda1 sudo mkfs.ext4 /dev/sda1
Now let’s create a file folder and give it the right permissions. This new file folder will represent our disk in the Raspbian file-system structure:
sudo mkdir /home/MyShares/public/MyUSBDrive sudo chown -R root:users /home/MyShares/public/MyUSBDrive sudo chmod -R ug=rwx,o=rx /home/MyShares/public/MyUSBDrive
I chose MyUSBDrive, but any name you like would work. Now let’s mount the newly formatted USB drive:
sudo mount /dev/sda1 /home/MyShares/public/MyUSBDrive
One last item of housekeeping. You’ll want this drive to automatically mount each time you reboot your Raspberry Pi. Otherwise it will be hassle to login to the Pi and mount it manually each time. To make it a permanent drive, issue the following command to edit the fstab configuration file:
sudo nano /etc/fstab
Add the following bit of configuration to the last line of the file:
/dev/sda1 /home/MyShares/public/MyUSBDrive auto noatime,nofail 0 0
Your Raspberry Pi NAS with external USB drive is now ready to go! When browsing from a PC or Mac you’ll see the MyUSBDrive folder inside the public shared folder.
OPTION 2: Build a Raspberry Pi NAS with OMV
Now let’s move on to option 2. Where Samba is a simple way to share files on a network OMV or Open Media Vault is a full blown NAS software for you Raspberry Pi that offers many advanced features, has web configuration and access, and all at the same time being incredibly simple to use and understand.
Unlike using Samba, where we need to install and configure Raspbian, Open Media Vault comes as a disk image that we’ll burn to our MicroSD card and install. This saves a lot of effort and makes the installation super simple. Word of caution, anything on your SD card will be erased. We recommend buying a second MicroSD card and swapping them out to protect your original card’s data while you experiment with OMV.
Download and Burn Open Media Vault
Head over to sourceforge and download the latest version of the Raspberry Pi OMV files.
Once you have the file, we’re going to burn it to your SD card using Balena Etcher. Etcher is a super easy drag-n-drop tool for burning image files to an SD Card. You can also use the tried and true Win32 Disk Imager if you’d rather.
Open Etcher, click Select Image. Choose the OMV image you just downloaded and then press the FLASH! button. Balena will burn the image to the SD card over the next few minutes and your OMV image will be ready to boot.
Prepare Your Raspberry Pi for OMV
The next step is to prepare your Raspberry Pi for OMV. This is pretty simple.
- Insert the OMV MicroSD card into your RPi.
- Connect one or more USB hard disks.
- (Recommended) Attach your RPI to your network with an Ethernet cable
- Plug in as your USB power supply to your RPi.
One note of caution. The Raspberry Pi has limited ability to power numerous devices and hard drives tend to consume a lot of power. We recommend using hard drives that are powered by their own power supply than over the USB port of the Pi. This can save you a lot of trouble down the road when things don’t act right for seemingly no reason.
Configuring Open Media Vault for Your Raspberry Pi NAS
Now we’re ready to get our Raspberry Pi NAS up and running with OMV. After OMV boots up your Raspberry Pi will show a message on the screen with the RPi’s IP address. In a browser on your PC or Mac, navigate to this address: http://your_OMV_ip_address/ In my case, http://192.168.1.44/
You should be greated with the Open Media Vault’s landing page.
The default login credentials for OMV are:
- Username: admin
- Password: openmediavault
Setting up your Disks and Folders
The last steps for getting your Raspberry Pi NAS on OMV setup is to add your disks and create some folders. On the left side navigation menu under the storage heading, click on File Systems. There you will see each of the USB hard drives you’ve attached. To add the drive, click it, select mount, and the apply. Do this for each drive you wish to add. Similarly you can remove drives by unmounting them.
Next up let’s create some shared folders to use. Again, it couldn’t be simpler. Under the Access Rights Management header, click Shared Folders. Click the add button to create a new folder. In this context window, you can also select which drive it will exist on (if you have more than one drive, any permissions you’d like to assign, etc. Just click save when finished.
Strangely, OMV does not enable SMB or CIFS out of the box. So these shared folders are not accessible to any devices just yet. In order to bring them to life on the network, we need to enable these sharing services.
Under the Services header on the left side navigation menu select SMB/CIFS. Select the enable radio button and then select save and apply. This will bring SMB/CIFS online and these files shares will now appear on your network.
The last step is adding users! On the Access Rights and Management header on the left side navigation menu click User. Click Add and then enter the users information. This can be anything you like, however for simplicity sake you make want to use the same username and password you used to login to your Windows PC or Mac. If you want an extra layer of security, make them something different.
That’s it! You’re finished. Accessing your files is exactly the same as above using the Samba server example. If you need help, scroll back up and read that section. You now have your very own Raspberry Pi NAS server that can share files with all of your home computers and devices!
Now to be honest, we’ve barely scratched the surface of OMV’s capabilities. Like many NAS servers, you can add data protection with RAID, mirror drives, sync data, etc. So start exploring the power of OMV. You’ll be glad you did!