logo
background
 Home and Links
 Your PC and Security
 Server NAS
 Wargames
 Astronomy
 PhotoStory
 DVD making
 Raspberry Pi
 PIC projects
 Other projects
 Next >>

Notes index links

Links to all my notes (includes mini-projects and source code etc)

(+) 0001 How do I change the Pi System partition size ?

(+) 0100 Device tree settings

(+) 0201 Power over Ethernet - (PoE)

(+) 0202 Solar Power - (with WiFi)

(+) 0203 Power Bank pass through

(+) 0400 Accessing the SDHC card system image

(+) 0401 Accessing PC shares from the Pi



(-) 0402 Installing samba - (the Pi as a Network Share on your PC)


As with everything *nix, it seems command and component names change with every new System release. Most of the guides you will find are based on the Raspbian Wheezy and NOT the 'latest' Raspbian Jessie - and the fact is, what 'works' with Wheezy does NOT work with Jessie. Since you must have Jessie for the Pi Zero I focus on Jessie ONLY.

NB. to check which Pi OS version you have, type "uname -a" at the command prompt. If you get something like 'Linux raspberrypi 4.4.11+ ..." that's Jessie (yeah, well, just like everything else in the *nix world you didn't think the OS would identify itself with anything as obvious as 'Jessie' did you ?)

Sharing a folder using samba

To 'push' data from the PC to the Pi across your LAN, you need to set up a 'share' on the Pi that can be 'mapped' from your Windows PC. This can be a real pain as it involves installing samba on the Pi

First ensure your Pi has the most recent list of the available 'update' packages :-

sudo apt-get update
Next, get and install the samba package :-

sudo apt-get install samba samba-common
Even if you have a 'direct' connection to the Internet (i.e. the Pi is plugged into your Router LAN directly, and not via ICS) it's still possible that one or more of the 'packages' will fail to download (or for the install itself to fail), so pay attention to the status reports that appear on the Terminal command line.

If the packages partially download, just type 'sudo apt-get install samba samba-common' again
If you get continuous "Could not resolve 'mirrordirector.raspbian.org'" errors, see at end of this note

Setting the samba user

Samba has it's own list of valid user accounts. To add 'pi' to the list of permitted samba users :-
sudo smbpasswd -a pi
If you get 'command not found' then samba has not installed correctly, so revisit 'Installing samba' above (retype 'sudo apt-get install samba samba-common')

Setting up a folder to share

Typically, you will be setting up a new folder on the Pi to 'share' with the PC  (or you can just share (all) the existing ones - see later). To set up a new folder eg 'photos' :-
sudo mkdir -m 777 /photos
The -m 777 means 'allow executable files' (scripts) to use this folder

Note - when you 'share' a folder, all 'sub folders' within it are also part of the share. This means, for example, if you 'mount' a USB memory stick as a 'sub-folder' to /photos/ - say /photos/usbroot - the contents of the USB stick plugged into the Pi now become visible to the PC user

Sharing the folder

Folders to be shared must be given a 'share name' - for example 'pi-share' - that the PC user will use to 'map network drive'. To do this, edit the /etc/samba/smb.conf file. For example, to share the folder created above (sudo mkdir /my-folder-for-PC) as 'pi-share':-

sudo nano /etc/samba/smb.conf
then add at the bottom :-
[pi-share]
comment = My share folder
path = /photos
browseable = yes
read only = no

To share the entire Pi system, set the share-name to something obvious (like [pi-root]) and set the path=/ 

To check what you entered into smb.conf :-
/usr/bin/testparm
NOTE: 'testparm' just lists the 'shares' = if you change the name of a 'target' folder (eg from /my-folder-for-PC to /photos) using 'mv' ("move"), the old folder is NOT 'moved' to the new name in smb.conf (it will continue to 'point' at the old folder).

This means the 'share-name' will become 'unlinked' from Pi source folder, although 'testparm' won't complain (although your PC will throw an error when it can't find the Pi mapped drive contents, perhaps even claiming 'network unavailable')

Activating samba

To ensure a 'clean' start-up, reboot the Pi :-
sudo reboot now
After samba has started OK for the first time, if you add (or change) the 'shares' in /etc/samba/smb.conf, all you need to do is restart samba (rather than reboot the Pi). To restart samba :-
sudo samba restart

Accessing the Pi samba share from your PC

If you know the Pi's IP address, then from 'My Computer', Tools, Map Network Drive. Enter the path to the Pi share-name folder (eg //192.168.0.103/pi-share) when asked for user, enter 'pi', password 'raspberry'.

If using Bonjour to find the Pi, you 'map' using 'raspberrypi.local' instead of the IP address (eg //raspberrypi.local/pi-share)


Pi Zero and "mirrordirector.raspbian.org" errors

Using a Pi Zero in RNDIS Gadget mode, when I attempted the 'apt-get' it successfully obtained the 'package lists' but then ended up with a series of "Could not resolve 'mirrordirector.raspbian.org'" errors.

'mirrordirector.raspbian.org' is a 'clever trick' by raspbian.org designed (I assume) to reduce loading on their servers by redirecting download requests to other sources, but (of course) I have no doubt this trips up all sorts of Firewalls, anti-virus and anti-'man-in-the-middle attack' prevention software on your PC.

The way out of this quagmire is (apparently) to bypass the 'redirect' by going direct to the raspbian.org servers :-
sudo nano /etc/apt/sources.list
replace 'mirrordirector' in :-
deb http://mirrordirector.raspbian.org/raspbian  ...
with 'archive'  as follows :-
deb http://archive.raspbian.org/raspbian ...

Needless to say, this didn't actually work for me, even after I manually downloaded raspbian.org's public key and installed it onto the Pi :-
wget http://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add -

Update - the 'mirrordirector' problem is not due to the RNDIS Gadget driver.

A Raspberry Pi B+ that would 'apt-get' just fine when wired direct to my LAN, exhibited the exact same 'mirrordirector.raspbian.org' errors as did the USB Gadget connected Pi Zero when wired to my Laptop (and thence via ICS and the laptop's WiFi link to the Internet) .

So (as usual) it's down to Microsoft and the way ICS works (or, in this case, doesn't work). You may have better luck using 'Bridging' (on the other hand, setting up on the B+ and moving the SDHC card to the Zero is faster)


This note last modified: 17th Sep 2016 08:10.

[top]

(+) 0900 Can this approach be scaled up to a PC UPS ?

(+) 1001 Pandora Spotify on the Pi

(+) 1002 Playing movies on the Pi

(+) 1003 Getting VGA from the HDMI socket

(+) 1004 Using the RCA socket

(+) 1005 Using the Pi RS232 serial links

(+) 1006 Using the GPIO pins

(+) 1007 Controlling the Pi Zero ACT LED

(+) 1200 List of standard camera modes

(+) 1300 Auto file names

(+) 6500 How to make the System partition read only ?

(+) 6501 Minimising SDHC corruption on power down

(+) 9000 diode switch

(+) 9001 Auto shut down

(+) 9001 MOSFET switch

(+) C201 High speed photos

(+) Dec 1969 (no desc)

(+) a000 Display setup - (for PhotoFrame)

(+) a001 go photoframe - (how it works)

(+) a002 set photo - (select for display)

(+) a003 go button script - (photoframe pause control)

(+) a005 get photos - (fetch resize)

(+) a00x Other display utilities

(+) c000 CCTV UPS requirements

(+) c001 countering low speed motion detect

(+) c002 Pi Overclocking

(+) c203 Pi ram disk - (tmpfs)

(+) c901 iR illumination

(+) c902 Viewing a video stream

(+) c905 Image anotation

(+) Dec 1969 (no desc)

(+) raspicamdocs.txt (no desc)

(+) s010 Elevation sensing

Next subject :- index

[top]