I recently bought a 2 terabyte Goflex Home network drive to run as a media server and file server on our local home network. So I figured I’d see how to connect it to the Pi. After searching around various forums, I found a solution that worked. Over the weekend, someone on the Raspberry Pi forums asked how to do this, and so a new “How To” was born.
Pre-requisites for Hooking up goflex drive
- the drive is already installed on your home network
- it’s fully up and running
- You have a userid and password
- You know the IP address of the network drive
OK let’s do it
From your command line, type…
cd ~ that puts you in your home directory
nano goflex.sh opens a file for editing and calls it goflex.sh
Then you need to type this command, changing the 192…….XXX to the Goflex IP address. Change username and password to your Goflex username and password, and you might need to change Home Public to whatever you want to connect to (e.g. Home Backup or Home Personal).
sudo mount -t cifs '//192.168.XXX.XXX/GoFlex Home Public' /home/pi/goflex/public -o username=blahblah,password=blahblah,iocharset=utf8,file_mode=0777,dir_mode=0777
You might notice I mounted it as a subdirectory of /home/pi This is to ensure you will have full read/write access from user pi. But before we do anything else, we need to create that directory and give it the right permissions…
mkdir goflex make directory called goflex
sudo chmod 777 goflex become super-user just for this command and change directory permissions to full read/write/execute for all users
Assuming you are connecting to “public” we need to create a directory and change its permissions just like we did for goflex.
sudo chmod 777 goflex/public
Make it executable
Now we need to make the script we just wrote executable so we can run it…
sudo chmod +x goflex.sh
Now, a drumroll and we’ll try to run it…
./goflex.sh (the reason for the ./ is because we are in the same directory as the file we want to run. Anywhere else we would type the full path to the file to run it.)
If you see the normal prompt and no error message, it worked. Now you can go there…
…and you should see a list of your directories/files :)
If it didn’t work, you’ll get an error message and most likely something in the script is wrong. Check, check, double-check.
Make the Connection Automatic on Boot (optional)
Once you’ve got it working, if you want it to connect every time the Pi boots up, carry on with the next part. I don’t use this myself (but I have checked that it works), as I don’t often want to connect to the network drive, so I’m happy to run the script as and when I need it.
We need to modify the script we wrote slightly.
Then add this right at the top
#!/bin/bash this will enable it to run when called from another script
Then we add a line to this file…
sudo nano /etc/rc.local
…this will open a file that contains stuff that runs at boot. This one won’t open unless you use sudo, as it’s a system file.
Go to the bottom just above the line which says “exit 0”. There you should type…
Then save and exit as usual
And then it should work whenever you boot up.
sudo reboot to give it a try.
I want more!
If you want to mount more than one of the Goflex folders, public, private and backup, you need to have a separate command in the script for each one. You’ll also need a sub-directory for each as we did above – as you can’t mount two “drives” to the same place. This may be obvious, but I thought I’d spell it out anyway. :)
Happy networking :)