Raspberry-Pi-3

Connecting NAS to Raspberry Pi

Raspberry Pi is excellent choice to run a low powered fully secure Linux based server . But with the passage of time you experience that the storage on the SD is not enough and some large enough space is required to keep files and backups. USB Hard Drive or a thumb drive could be a work around . Thumb Drive again limit the capacity and USB SATA devices can be hard to manage in terms of physical setup.
Raspberry Pis have 100Mbps ethernet adapter built in which could be used to connect a network drive (NAS) or other file share .
First step is to create the share folder and user on your NAS .  In my case it was WD My Cloud I created user and set a password for that user in NAS.
Mounting the Share to Raspberry Pi
First Login to pi and create a dircetory where we will mount the NAS

pi@raspberrypi:~ $ sudo mkdir /mnt/mycloud

Mount and Test the NAS Share to pi

pi@raspberrypi:~ $ sudo mount -t cifs -o user=pi,passwd=verylongpassword ,rw,file_mode=0777,dir_mode=0777 //192.168.1.10/pi /mnt/mycloud

User  is pi which was created on WD NAS  ie 192.168.1.10 with the password “verylongpassword” but in my case WD My Cloud is not accepting more than 16 characters passwords.
Permanent Mounting
The above command will mount the NAS to pi but it will not be available after reboot. To make this derive permanent we have  to add the settings of the drive in /etc/fstab . Open  fstab with any text editor

pi@raspberrypi:~ $ sudo nano /etc/fstab

 
You will see the list of entries add the last lines as example

roc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that

Enter the Line in end of file as highlighted

roc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that
#Mounting the NAS
//192.168.1.10/pi /mnt/mycloud cifs _netdev,user=pi,passwd=verylongpassword,rw,file_mode=0777,dir_mode=0777,iocharset=utf8,comment=systemd.automount 0 0

Hit Ctrl+X and save .
Reboot your Raspbery pi and after login run df -h to see your NAS is mounted on /mnt/mycloud

pi@raspberrypi:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 5.5G 8.6G 39% /
devtmpfs 427M 0 427M 0% /dev
tmpfs 432M 0 432M 0% /dev/shm
tmpfs 432M 6.2M 425M 2% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 432M 0 432M 0% /sys/fs/cgroup
//192.168.1.10/pi 2.7T 896G 1.9T 33% /mnt/mycloud
/dev/mmcblk0p1 63M 21M 43M 34% /boot
tmpfs 87M 0 87M 0% /run/user/1000

Network Drive Bench Mark
Running a simple benchmark on Network drive shows fair Read and Write Speed over 100Mbps Pi Ethernet . First Highlighted line is for Write and Last one is Read Test.

pi@raspberrypi:/mnt/mycloud $ ./diskbench.sh
dd if=/dev/zero of=test.tst bs=4096 count=100000
100000+0 records in
100000+0 records out
409600000 bytes (410 MB) copied, 34.855 s, 11.8 MB/s
dd if=test.tst of=/dev/null bs=4096 count=100000
100000+0 records in
100000+0 records out
409600000 bytes (410 MB) copied, 36.612 s, 11.2 MB/s

Posted

in

, , ,

by

Tags:

Comments

2 responses to “Connecting NAS to Raspberry Pi”

  1. Raul Arellano Avatar
    Raul Arellano

    Hey,
    Thanks for the tutorial.
    I have been trying to do something similar and have not found a solution. I even tried posting in a forum but I dont get much help.

    I have a WD My Cloud Home 8TB.
    It is a consumer option with no access options and it is slow and makes thumbnails for about 3 weeks if I have to restart it. I dont like it.

    So I got a Pi4 4GB and a usb adapter and now I have it connected to the Pi4. All I want to do is to set up a media server and a cloud service which I would like to connect even when I am not home. I am having trouble finding the files inside the HD.

    Here is where I am now:

    https://www.raspberrypi.org/forums/viewtopic.php?t=255138

    Any ideas you can give me to finish this little project?

    Thanks!

    1. Affan Javid Avatar

      WD stores data on different partitions of the Drive. File system used is ext file system. Yes devices are terrible and slow. I prefer freenas over it. Try running “find / – name HD” . (HD in capital) WD stored data in directory name like /mnt/HD/HD_a2 etc. The put folder will have all share folders you have created on WD.