NAS = Network Attached Storage is simply an external hard disk or more disc serving as your home storage cloud. You can simply access these disks from any of your devices in home and read or store data. More about NAS you can find at Wikipedia.
Now we will show you how to create your home NAS for hobby purposes.
Get these hardware pieces
|Raspberry Pi 2, 3, 4 with any case and power adapter|
|Tenda 300 Kbps USB dongle or better|
|Icy box – USB 4.0 Hub or better|
|External 3.5″ HDD|
Insert Raspberry into the case, connect external HDD via USB hub and plug-in power adapter.
Prepare Raspberry Pi
Prepare Raspberry Pi working with Raspbian OS. More here…
Install additional software
$ sudo apt-get update $ sudo apt-get install ntfs-3g
$ sudo apt-get install samba samba-common-bin
Samba contains the SMB protocol, support for the Windows naming service (WINS), and support for joining Windows workgroups. A workgroup is a group of computers on a local network that can access eachother’s folders. Samba-common-bin contains a tool that you’ll need to register users with Samba.
Set HDD delay during boot up
Setup a time delay for external HDD when Raspberry Pi is booting up.
$ sudo nano /boot/cmdline.txt
Add at the end on line: rootdelay=5
External folders where to mount HDD
Now create folders where to mount your external HDDs (example of 4th disks)
$ sudo mkdir /mnt/NAS1 $ sudo chmod 775 /mnt/NAS1 $ sudo mkdir /mnt/NAS2 $ sudo chmod 775 /mnt/NAS2 $ sudo mkdir /mnt/NAS3 $ sudo chmod 775 /mnt/NAS3 $ sudo mkdir /mnt/NAS4 $ sudo chmod 775 /mnt/NAS4
Check disks and their UUIDs
$ sudo blkid
$ sudo fdisk -l
$ ls -l /dev/disk/by-uuid/
Add automatic mounting
$ sudo nano /etc/fstab
At the end of the file add code below where you ave to replace “number” with a real UUID of your disks:
UUID="number" /mnt/NAS1 ntfs-3g rw,defaults 0 0 UUID="number" /mnt/NAS2 ntfs-3g rw,defaults 0 0 UUID="number" /mnt/NAS3 ntfs-3g rw,defaults 0 0 UUID="number" /mnt/NAS4 ntfs-3g rw,defaults 0 0
UUID="0CBA7BADBA7B91C6" /mnt/NAS3 ntfs-3g rw,defaults 0 0 UUID="54D8D96AD8D94ABE" /mnt/NAS1 ntfs-3g rw,defaults 0 0 UUID="216383C50C8DFED1" /mnt/NAS2 ntfs-3g rw,defaults 0 0 UUID="A2CA0AEBCA0ABC13" /mnt/NAS4 ntfs-3g rw,defaults 0 0
After restart you should see in folders /mnt/NASx your external disks.
Configure SAMBA to provide external disks in network
$ sudo leafpad /etc/samba/smb.conf &
Find the entries for workgroup and wins support, and set them up as follows:
workgroup = your_workgroup_name wins support = yes
The name of the workgroup can be anything you want, as long as it only contains alphabetical characters, and it matches the name of the workgroup that you want to join.
You also need to add the following section of code to smb.conf below Share Definitions section:
[Video] comment= Home videos path=/mnt/NAS1/Data/Video browseable=Yes writeable=Yes only guest=no create mask=0777 directory mask=0777 public=no valid users = pi
The path should point to the drive or folder that you want to share. Please don’t use spaces in the name in brackets.
Now type this command in a terminal, and enter pi’s password twice:
$ sudo smbpasswd -a pi
Connect from client devices
Now connect external folders permanently from clients (your PC, laptop, etc…).
Check if the disc are available via server connection: smb://192.168.1.x/ and get their addresses (//192.168.1.x/Disk1)
Then connect them permanently. Edit following file:
$ sudo gedit /etc/fstab
And add this line of code:
//192.168.1.x/Disk1 /mnt/old cifs username=login,password=pasword,uid=65534,gid=65534,file_mode=0777,dir_mode=0777,iocharset=utf8, 0 0
Do not forget to change your real disk IP and address. Finally reboot Raspberry and your NAS is ready.