Network Attached Storage(NAS) Using BrainyPi
by dhruvarora561 in Circuits > Electronics
97 Views, 1 Favorites, 0 Comments
Network Attached Storage(NAS) Using BrainyPi
A Network-attached storage(NAS) allows you to save files from computers/ phones on a network to another device which is connected on the same network. Using BrainyPi we can achieve this very easily.
A NAS is a great way to backup important data so that it can be recovered in case of data loss.
Supplies
We'll need a few things before we get started
- BrainyPi or raspberry pi
- Keyboard and Mouse
- External storage(optional)
Installing Samba
Samba is the protocol which allows windows/linux computers to share files over the network.
- To install samba, run(on brainypi)
sudo apt update && sudo apt install samba -y
Testing the Installation
2.1 After installation we need to check if the installation was successful or not. Run the following
whereis samba
2.2 If the output is similar to this then you are good to go!
samba: /usr/sbin/samba /usr/lib/arm-linux-gnueabihf/samba /etc/samba /usr/share/samba /usr/share/man/man7/samba.7.gz /usr/share/man/man8/samba.8.gz
Mounting External Drives
Now, we are going to set up mount points for the external drives.
3.1 Start by creating a mount point
sudo mkdir /mnt/hdd
3.2 Now we find out the name of the external drive
fdisk -l
Hint: Look for the partition starting with "/dev" that has the matching size to your disk
3.3 Mounting the drive to the mount point. Change the mount point and partition based on the values received from the above commands.
sudo mount /dev/sdb2 /mnt/hdd
Here, /dev/sdb2 is the value we received from fdisk -l command and /mnt/hdd is the mount point we created earlier.
3.4 Verification, run the following command to verify if the disk was mounted successfully
ls /mnt/hdd
Setting Up Automatic Mounting
We need to modify the fstab file to setup the automatic mounting when the device boots up.
4.1 First we run this command to get the UUID of our drive.
sudo blkid
4.2 Now we are going to edit the fstab file.
sudo nano /etc/fstab
4.3 Add the following lines, but replace the UUID and the mount point
UUID=enterUUIDhere /mnt/hdd fstype defaults,auto,users,rw,nofail 0 0
4.4 Testing the mount. Run the command to see if the drives mounts or not
sudo mount -a
Configuring Samba
3.1 Start by opening samba configuration file
sudo nano /etc/samba/smb.conf
3.2 Now, scroll to the end of the file and add the following
[Any name you want to give]
comment=any comment
path=/path/to/your/folders
browsable=yes
read only=no
guest ok=no
3.3 If you want to add more folders, just add the above code for each folder.
3.5 Setting up user accounts for samba.
NOTE: The user should be a system user otherwise the password will not save.
sudo smbpasswd -a pi
Connecting to Share
4.1 To test, using any linux/windows machine on the network
4.2 For ubuntu, go to any file manager and click "connect to server", then type the following
smb://ip-address-of-pi/sambashare
4.3 For windows, press "windows key+r", then type
\\ip-address-of-pi\sambashare\
enter username and password, then press enter.
4.4 If the above fails, repeat the steps again to rectify the errors