How to mount remote hard drive to Raspberry Pi 3B+
Hello, here is a quick way to mount a remote hard drive via Lan or Wireless connection.
I have mounted Western Digital MyBook Live attached with lan cable to the router and Seagate Backup Plus plugged in USB port on the router. WD has lan address itself and Seagate has lan address of the router, because its USB connected.
Method is identical for both devices:
1. You need to create the folder in which we are going to mount the hard drive:
sudo mkdir /mnt/MOUNTDIRNAME
In my case is /mnt/mybooklive and /mnt/seagate. Of course, you may have only one device.
2. You need to actual mount the drive into the folder via IP Address:
sudo mount -t cifs -o vers=1.0,username=guest,password=,gid=1000,uid=1000,file_mode=0777,dir_mode=0777,nofail //IPADDRESS/FOLDER /mnt/MOUNTDIRNAME
Example:
#EXAMPLE
sudo mount -t cifs -o vers=1.0,username=guest,password=,gid=1000,uid=1000,file_mode=0777,dir_mode=0777,nofail //192.168.0.2/Public /mnt/mybooklive
//192.168.0.2/Public – the IP and shared folder on the hard drive
/mnt/mybooklive – the folder we just created
Of course, if you have added users and separated them in folders, you have to change username=guest,password= to yours.
3. Change permissions to folders. Sure, you mounted them, but can you write in folders? No, unit you give them access, like so:
sudo chgrp -R users /mnt/MOUNTDIRNAME
sudo chmod -R g+w /mnt/MOUNTDIRNAME
4. You actually can write now the command from 2. every time the machine starts or restarts, but eventually will get annoying :).
sudo nano /etc/fstab
You need to add 1 command at the end of the file in fstab to make hard drives mount automatically:
//REMOTEIPADDRESS/REMOTEFOLDER /mnt/MOUNTDIRNAME cifs vers=1.0,username=guest,password=,gid=1000,uid=1000,file_mode=0777,dir_mode=0777,nofail 0 2
Example:
#EXAMPLE
//192.168.0.2/Public /mnt/mybooklive cifs vers=1.0,username=guest,password=,gid=1000,uid=1000,file_mode=0777,dir_mode=0777,nofail 0 2
//192.168.0.2/Public – the IP and shared folder on the hard drive
/mnt/mybooklive – the folder i created for mounting
Note that here last two parameters are first. Again, if you have added users and separated them in folders, you have to change username=guest,password= to yours.
Hope that helps 🙂
Photo by: Patrick Lindenberg