Pages

Tuesday, February 18, 2014

How to mount a Windows/NAS share on your Raspberry Pi

If you have a Raspberry Pi and a Windows machine (or maybe a NAS), you might want to share folders from the Windows machine/NAS to the RasPi.
One reason to do this (apart from sharing content between the two machines) would be to use the NAS as Mass Storage for the Pi.

This tutorial presumes you have already set up a shared folder on your NAS/Windows machine (we will call this \\Machine\SharedFolder), and that you have Raspbian installed on your RasPi's SD card.

These are the steps:

1. Create a mount point on the Raspberry Pi:

sudo mkdir /mnt/folder 

(obviously you can give it the name you prefer)

2. Open /etc/fstab to edit it:

sudo nano /etc/fstab

3. Add the following line at the end of the file:

//Machine/SharedFolder /mnt/folder cifs defaults,rw,credentials=/home/username/.cifscredentials 0 0 

where:
//Machine/SharedFolder stands for your Windows/NAS share
/mnt/folder stands for the folder you created in step 1
/home/username stands for your pi's username (default is "pi")

4. Now we have to create a file for storing Windows credentials:

nano /home/username/.cifscredentials

and insert your Windows credentials in it:

username=winuser
password=winpassword
domain=WORKGROUP 

5. Change the permissions to this file, in order to avoid undesired access to your credentials:

sudo chmod 600 /home/username/.cifscredentials

6. Let's see if it works:

sudo mount -a

If it worked, the following command will list the contents of the shared folder:

ls /mnt/folder

Is it all ok? Good!

7. Now reboot your Raspberry Pi (command is: sudo reboot) and when it comes back on, try again with:

ls /mnt/folder

The shared folder should have been mounted automatically.
Enjoy!

No comments:

Post a Comment