Pi Quick Ref, Raspberry Pi, Raspian, Windows 10

Rapsberry Pi: Mount a windows share as a Pi directory

This post describes how to set up a shared folder on your PC and then mount it as a directory on your Raspberry Pi. This is useful for projects that will be writing large files and you don’t want to risk filling up your SD card, for example when using the camera.

First, on your PC, create a folder in File Manager and set it up as a share:

windows share

I’m assuming you already have PuTTY installed on your PC and have set up a headless connection to your Pi; also you should have Raspian configured to “Wait for Network at Boot” (if not see this post).

Open a terminal window to your Pi using PuTTY and type the following command to edit the fstab file:

sudo nano /etc/fstab

… and add the following line at the end of the file (enter all on one line and enter your Windows username/password you set up the share with above):

//LENOVO-PC/PiCamShare /mnt/PiCamShare cifs username=WindowsUser,
password=WindowsPwd,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0

Save the changes and exit the editor (type Ctrl+X, Y, then press Enter) then reboot your Pi (enter the command sudo reboot)

Open a new terminal window and enter the command:

df -h

… which should show the mounted windows share …

df -h mounted

(If you don’t see the share listed then see the Trouble Shooting section below).

Now test you can write to the file on your Pi and PC:

In the terminal window enter the commands:

cd /mnt/PiCamShare 
nano mytest.txt

… and enter some text.

On your PC open File Manager and open the shared folder; you should see the mytest.txt file.  Edit the file (using Notepad or similar) adding some more text.

Back in the terminal window, enter the following command:

cat /mnt/PiCamShare/mytest.txt

… and you should see all the text you have entered in the file.

Trouble Shooting: If the share does not mount

If the share is not shown as mounted when you enter the df -h command after the reboot then run the following command:

sudo raspi-config

… and set the option Wait for Network at Boot to  Slow Wait for network connection

Reboot and reconnect then run the df -h command to see if the share now mounts.

If the share still has not mounted then enter the following commands in the terminal window:

sudo mount -a
df -h

If this now shows the share has been mounted, enter the following to edit the interfaces file:

sudo nano /etc/network/interfaces

… put a # in front of the line iface eth0 inet manual

… and add the new lines …

auto eth0
iface eth0 inet dhcp

… that is:


Now reboot the Pi, open a new terminal window and re-enter the command df -h and this should show the share has been mounted automatically.

Test as above by creating a test file and edit it on both your Pi an PC.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s