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 😉

 

8 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 🙂

  2. Hi Allyn
    I’ve followed your tutorial and the NAS mounted OK and all worked.the problem I’m having is that i cant get it to auto mount i followed your instructions but when i reboot the drive doesn’t mount

    • Hi there,
      What exactly are you trying to mount the NAS too? A Raspberry Pi?
      When you log in does the drive mount when you type:
      sudo mount -a
      Does the mount appear when you type?:
      cat /etc/fstab

      • Yes im trying to mount it to a raspberry pi 3 b+
        no the drive doesn’t mount when i type the lines you said. here is a copy of the screen

        pi@muisic:~ $ sudo mount -a
        mount.nfs: remote share not in ‘host:dir’ format
        pi@muisic:~ $ cat /etc/fstab
        proc /proc proc defaults 0 0
        /dev/mmcblk0p6 /boot vfat defaults 0 2
        /dev/mmcblk0p7 / ext4 defaults,noatime 0 1
        # a swapfile is not a swap partition, no line here
        # use dphys-swapfile swap[on|off] for that
        //192.168.0.200/Public /home/pi/wdmycloud nfs default 0 0

  3. Hi,

    awesome tutorial! I tried to use this in order to have my Pi doing all major downloads in the background and storing them on the MyCloud, which would be fantastic.

    Allyn, above you mentioned recalling permission-issues. I also had permission problems and tried to resolve them by changing the owner of the /home/pi/wdmycloud to the user “pi” (it seems to have been root) and by changing permissions with
    $chmod a+rwx
    both -R recursively.

    Now I am actually able download into /home/pi/wdmycloud/downloads with Raspbian, but the files seem to be stored locally on the SD. At least they show up there, but not in the MyCloud (192.168.X.X/Downloads in my case) when connecting directly to it from my computer.
    Does changing permissions somehow crash the link? (Sorry for any noob silliness).

    and by setting

    • Hi onophrio,

      It’s great to hear you got this working 🙂
      Changing the permissions shouldn’t impact the links. How are you copying the files?
      Are you doing something like rsync, or are you doing a cp command?

      It appears to be a common issue on Raspberry Pi’s that when people reboot them they lose the mount. So have you verified that your mount is still working on a reboot?
      It may be worth manually checking the mount, then copying the files.
      If the mount is lost – maybe your copy file command is actually creating the /home/pi/wdmycloud/downloads directory and that’s why you’re seeing the files on your SD card?
      Any files or directories you create should be on the NAS, not on your SD card. You’ll be able to view the files from your Pi, of course, but they shouldn’t be taking up space there.

Leave a Reply

© 2019 Allyn H

Theme by Anders NorenUp ↑