Raspberry Pi: NAS Server
Summary
This Documentation is a step by step guidance to convert your Raspberry Pi into a NAS Server for your Home Network.
Requirements
- at least Raspberry Pi 3B+
Use Cases
The main use case is to storing data, but I personally use it for decentralized programming for the Languages Python, Node.js and PHP. It is quite handy to open NAS based directories with programming editors, like sublime and visual code.
Description
Step 1: Updating the package repositories of your system
sudo apt update sudo apt upgrade
Step 2: Install Symbian
sudo apt install samba samba-common-bin
Step 3: Create the NAS folder
Option 1: Use the MicroSD Storage
sudo mkdir /home/SharedDirectory
Option 2: Use an externally mounted USB Drive
Searching for Mountable USB drives:
sudo fdisk -l
Create a mount folder:
mkdir /media/usb-drive
Mount the USB Drive
mount /dev/<device name> /media/usb-drive/
Step 3: Configure Samba
sudo nano /etc/samba/smb.conf
Add these lines and modify them as you need:
[Drive Name] comment = comment writeable = Yes browseable = yes path = /home/SharedDirectory create mask = 0660 directory mask = 0771 public = yes
[Drive Name] | The Displayed folder name |
comment | A comment to the drive |
writeable | 'yes' for read and write and 'no' for read only |
browseable | Specifies if the Drive is visible in your network |
path | The directory which gets used for the NAS server |
create mask | The Unix Permissions for new created files |
directory mask | The Unix Permissions for new created folders |
public | Allows everybody to access the NAS server. Use 'valid users' to restrict access |
Optional step: Create a folder that gets cleared periodically
This folder is meant if you want to transfer data form one machine to another without using an flash drive.
sudo mkdir /home/SharedDirectory/TemporaryFilesDirectory
Make an corn job to periodically delete the Directory content.
crontab -e
m h dom mon dow command 0 * * * * rm /home/SharedDirectory/TemporaryFilesDirectory/*.*
This specific cronjob will be exicuted at the sart of every hour. You can choose your prefereds timeslots by editing the '0' and '*'
Used Hardware
Raspberry Pi 3B+