Sometimes it can be useful, and above all convenient, to access folders on a NAS or even on another computer from your Raspberry Pi. There can be many reasons for this; personally, I have found this mapping useful both for accessing files on my Mac and for backing up some Raspberry Pi configurations to a NAS.
To do this, as always, log in to your Raspberry Pi via SSH and, once logged in, create a folder (wherever is most convenient for you to access it when you need to reach the NAS).
sudo mkdir /home/pi/Desktop/Share
now we just need to schedule access to the NAS folder in crontab, so open crontab with the command:
sudo crontab-e
the first time you run crontab, you will be asked which editor you prefer to use to edit the file (personally, I prefer nano).
now move to the end of the file and add the following line:
@reboot sudo mount -t cifs -o user=nas_username,password=nas_password,rw,file_mode=0777,dir_mode=0777 //192.168.1.200/BKT /home/pi/Desktop/Share
Of course, replace nas_username with the username used to access the shared folder, nas_password with the corresponding password, and 192.168.1.200/BKT with the network path you want to map.
This command “maps” the chosen network drive with the relevant login credentials every time the Raspberry Pi restarts
Now save your changes (if you chose the nano text editor, press CTRL+X and ENTER to confirm) and you’re done!
Enjoy!
