Find Out What’s Available
The first thing I did was to show all the mount points available on the server where the network share is:
$ showmount -e 192.168.1.4
The result should be something like this:
Export list for 192.168.1.4: /Recordings /Multimedia /Download
Create Mount Folder in the Raspberry Pi
Then I created a folder in /mnt
so that I can mount the network share on the folder:
$ sudo mkdir /mnt/multimedia_share
OPTIONAL: Mount Manually Before Attempting To Auto-mount
I manually played around with the mounting before actually trying to get it to auto-mount. A fun exercise for n00bs like me.
If the network share allows anonymous access, the following command should “map” the network share to the /mnt/multimedia_share
$ sudo mount -t cifs -o guest //192.168.1.4/Multimedia /mnt/multimedia_share
Otherwise, a mount error will be returned:
mount error(13): Permission denied Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
If the network share requires credentials for access, the following command should be used:
$ sudo mount -t cifs -o username=user_name,password=plain_text_password //192.168.1.4/Multimedia /mnt/multimedia_share
To unmount, use the following command:
$ sudo umount //192.168.1.4/Multimedia
Configure Auto-mount on Boot
If we manually mount the network share, we will lose the “mapping” once the Raspberry Pi reboots. To have it mount upon boot, we have to edit the /etc/fstab
file:
$ sudo nano /etc/fstab
Add the following line at the end of the file:
//192.168.1.4/Multimedia /mnt/multimedia_share cifs username=user_name,password=plain_text_password,file_mode=0777,dir_mode=0777 0 0
Save the file and run the following to have the network share mounted:
$ sudo mount -a
There wouldn’t be any feedback like a success message if there are no errors. So to see if the mount was successful, run the following:
$ df -h
That command should return something like this:
Filesystem --- Size --- Used --- Avail --- Use% --- Mounted on /dev/root --- 15G --- 2.9G --- 11G --- 21% --- / ... //192.168.1.4/Multimedia --- 5.4T --- 3.1T --- 2.4T --- 58% --- /mnt/multimedia_share
Note the last line where the details of the network share is displayed including the total size, used and available space.
To test if the auto-mount configuration worked, reboot the RPi:
$ sudo reboot
After it restarts, connect to the RPi and try to access the contents of the network share by going into:
$ cd /mnt/multimedia_share