I ended up following this tutorial:
http://www.bitpi.co/2015/02/16/accessing-a-windows-share-with-a-raspberry-pi/
On Windows:
The article is for Windows 8, so the network settings UI in Windows 10 was a bit different, but managed to find everything.
- turn on network discovery (for the private network only)
- turn on file and printer sharing (for the private network only)
- choose the folder to share, as well as choose a Windows user to whom the access privileges will be granted to (it can be your normal Windows user), and set up (via checkboxes) which privileges should be granted when accessing via the network
- the little sharing setup window will reveal the "network path" of the shared folder, pay attention to that, will need it when mounting
Finding out the Windows machine's LAN IP address is also necessary: the ipconfig
command issued in Powershell reveals it.
Extra task:
My Windows 10 does not set up my LAN network automatically as Private (however, the sharing was set up only for private networks).
Launch Powershell with Administrator rights to fix that:
# This will reveal — among other things — the "Name" of the LAN
Get-NetConnectionProfile
This sets it private
Set-NetConnectionProfile -Name "the value of 'Name' from the previous command" -NetworkCategory Private
On Ubuntu:
Prepare a mount point:
sudo mkdir /mnt/my_windows_stuffs
sudo chown LinuxUserNameHere:LinuxUserNameHere /mnt/my_windows_stuffs
Install cifs-utils
, which is sort of a partial drop-in for samba; the smbclient
and winbind
packages will be installed automatically as its dependencies.
sudo apt install cifs-utils
Mounting with cifs
:
sudo mount.cifs //WINDOWS.IP.ADDRESS.HERE/path/on/windows /mnt/my_windows_stuffs/ -o user=WindowsUserNameHere,uid=$(id -u),gid=$(id -g)
Remarks on some select arguments:
//WINDOWS.IP.ADDRESS.HERE/path/on/windows
Note that from the "network path" that Windows suggested (and which contains the Windows machine's name as server identifier), we use only the filesystem path. The machine's name will be replaced by the Windows machine's LAN IP address. It still needs to be preceded by //
.
user=WindowsUserNameHere
The above linked tutorial suggested providing an option — in addition to user
— for the password too, but that could end up as plain text in ~/.bash_history
, which is better avoided.
However, if this password option is omitted, then one will be prompted for it interactively, and it can be entered in a similar fashion as Linux's sudo password.
An additional possibility would be to use the credentials
option to point to a file containing the user & password values. This option would be the best fit, when the mount instruction needs to go in /etc/fstab
. See more about this in the below linked documentation.
uid=$(id -u),gid=$(id -g)
Without these options the contents of the mounted folder would not be writable, even if on the Windows-side the write permission were granted. It's because even though the mount folder was given to our regular user during our preparation, cifs would still put the content into it as root: all content inside would still be owned by root.
We need to tell cifs to handle the contents on our regular user's behalf.
The options of uid
and gid
will achieve that. To find out their values up-front, one can run the id -u
and id -g
commands correspondingly. These will return our regular user's user- and group ID.
This however can be made automatic, with using dynamic substitution in the command itself, as seen in the above snippet.
Note that if Windows is sending ownership information along with the content, the further forceuid
and forcegid
options (no values needed) might also be necessary.
(I have learned about these latter options from @Huygens' answer on the Unix SE site.)
At this point the desired Windows content should be available in the /mnt/my_windows_stuffs/
directory.
Note that using plain rsync
on this mount will be extremely slow. Unfortunately, this is expected. Normal copying however works at reasonable rates.
When done working with these files, the Windows machine can be unbound with:
sudo umount /mnt/my_windows_stuffs/
See more in the mount.cifs
documentation.