Allyn H

Making things, writing code, wasting time...

Connecting a Raspberry Pi to a WD MY Cloud Network Attached Hard Drive:

Recently during a house move, I dropped my good old reliable Raspberry Pi – hard drive Network Attached Storage unit.
Basically I connected my external hard drive to a Raspberry Pi and had a Network Attached Storage drive which allowed me to access my media from any device on my home network.

I then realised it was time to buy a dedicated NAS.

I shelled out for the WE My Cloud 4 TB server, which by all reports is a great piece of gear – however I wanted something more than a standalone NAS and I wanted to be able to access the WD My Cloud from my Pi.

Here’s how I connected my Pi to the My Cloud! The guide below should work for any NAS – not just the WD My Cloud.

Find the IP address of your NAS:

If you don’t know the IP address of your NAS, you can perform an “arp-scan” from your Raspberry Pi to find it, here’s how I found mine:

# sudo arp-scan --localnet --interface=wlan0

If you still can’t find the IP address, for the WD My Cloud you can find the IP address in your settings, as per the instructions here.

In my case my NAS IP address was: 192.168.192.62

Mounting the NAS to the Raspberry Pi:

The first step to accessing the NAS from your Raspberry Pi is to mount the external HDD as a file system on the Raspberry Pi, this will allow you to view the NAS, as you would any directory on the Pi. This is pretty easy actually, as the CIFS (CIFS Common Internet File Share, a protocol dictating how different OS’ share files between them, including Windows and Linux) protocol takes care of everything.

First make a directory for the share:

# mkdir wdmycloud

Next mount the drive using the IP address and the Raspberry Pi directory you want to mount to:

# sudo mount -t cifs -o guest //192.168.192.62/Public /home/pi/wdmycloud
mount command

mount command

In this example, I am mounting the “Public” folder located on my NAS to the wdmycloud folder located on my Raspberry Pi.

The command syntax is:
mount -t <Mount Type> -o <Access> <SOURCE> <DESTINATION>

After executing the mount command, you should now be able to access the NAS file system as you would any other directory!

Automatically mount the NAS on power up:

 

Edit the FSTAB to mount your NAS automatically on power up:

To make the mount permanent, we need to add the NAS file system to the Raspberry Pi’s /etc/fstab file – the File System Table.

# sudo nano /etc/fstab
Edit the FSTAB file.

Edit the FSTAB file.

Add the NAS as a file system in the FSTAB file.

//192.168.192.62/Public /home/pi/wdmycloud cifs guest     0       0
Adding the NAS to the FSTAB.

Adding the NAS to the FSTAB.

You can see from the last line in the FSTAB file above, I have added the NAS as a file system in my FSTAB file.

This will automatically mount the NAS every time you power up your Raspberry Pi!

Testing the NAS is connected automatically on power up:

First step, reboot your Pi… :

# sudo reboot
Reboot your Pi.

Reboot your Pi.

 

Next step, check your NAS directory from the Pi:

# cd wdmycloud
# ls -larth
Confirm the share is working.

Confirm the share is working.

Success! The mount works, I can now access all of my pictures, music and movies from my Raspberry Pi. Everything is safely stored on my WD My Cloud, which keeps 2 copies of all of my data – so if anything goes wrong, I’ll always have my data backed up 😉

 

2 Comments

  1. Hi Allyn,
    nice work! just what I needed to get my WDmycloud working with Rpi.
    I still have a couple of issues that I cannot resolve.

    1. I have added the line to FSTAB however it does not work on my Rpi3. I am guessing it is trying to mount the NAS before the network is up. Any ideas?
    2. I can only write to the public directories using SUDO, – CHOWN does not work.
    BTW there is a typo:

    # cd mywdcloud – should read # cd wdmycloud

    Cheers

    • Hi David,
      I’ll have to check this out again. Shortly after writing this, during a house move, my Pi was dropped and broke!

      I think for what I was doing, read access was enough, at the time. I do recall permission issues, but I’ll need to check again.

      I’m on holiday at the moment and will try it out when I get home.
      I’ve fixed the typo – thanks 🙂

Leave a Reply

© 2017 Allyn H

Theme by Anders NorenUp ↑