This gist will cover mounting a network drive to your raspberry pi. This is being tested on a raspberry pi running Raspbian Stretch.
The process is assuming you have a windows network drive already setup on your network and the proper permissions configured. The following snippet shows our assumptions:
ip = 192.168.1.10
windowsUser = user1
userPass = password
sharedDriveName = shared
You will need to install cifs-utils
from the raspbian package manager using the following command:
sudo apt-get install cifs-utils
Then create the directory you want the shared drive to mount in. In our case, this will be at /mnt/shared
. We will also change the permissions so that our pi
user has permission to modify this directory.
mkdir /mnt/shared
Now we will add an entry into our /etc/fstab
to get the shared drive to mount whenever the raspberry pi boots. Use your preferred text editor to open up /etc/fstab
and append the following entry to the bottom of the file.
sudo vim /etc/fstab
# /etc/fstab
//192.168.1.10/shared /mnt/shared cifs username=user1,password=password,iocharset=utf8,sec=ntlm,vers=2.1,uid=1000,gid=1000,x-systemd.automount 0 0
Now, when your raspberry pi boots up, you should see the network drive contents at /mnt/shared/
.
note: if your shared drive is failing to mount, you can view your kernal log using
sudo tail -f /var/log/kern.log
if there is an error selecting the appropriate authentication method, you can try removing the sec=ntlm
option and changing the fstab entry to:
//192.168.1.10/shared /mnt/shared cifs username=user1,password=password,iocharset=utf8,vers=2.1,uid=1000,gid=1000,x-systemd.automount 0 0