1

I have the following problem: I have 2 Raspberry Pi in my network and want to mount a directory from my Raspberry Pi 2, running Samba version 4.2.14-Debian to my new Raspberry Pi 4 running Samba version 4.9.5-Debian.

On my Raspberry Pi 2 I defined in /etc/samba/smb.conf

[test]
  valid users = pi
  guest ok = yes
  path = /home/pi/test
  writeable = yes

Now I can mount this drive on my Windows 10 PC:

Win10 PC

Now I tried on my Raspberry Pi 4 to mount this directory:

$ sudo mount.cifs //192.xxx.yyy.29/home/pi/test /home/pi/test -o user=pi,pass=xyz

but I get always the error message:

mount error(2): No such file or directory
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

I played around with the version option and tried all versions from 1.0 to 3.1.1 but no success :(

5
  • Since you have a Pi2 and Pi4 you will also want to look at any samba version differences. Beginning with samba 4.5, the NTLMv1 auth was disabled. You will need to use v2. You can specify that in your mount.cifs command line as an option after -o with sec=ntlmssp. Win10 has also messed with the default auth over the last year. (I don't have details there -- but that should be part of your inquiry as well) Commented Aug 19, 2021 at 18:55
  • How can I move this question to Raspberry pi StackExchange. Or do I need to create a new post there? Sorry, I am a newbie.
    – Detlev
    Commented Aug 19, 2021 at 18:57
  • Flag your post and ask a moderator to move it. But a very simple question: does the target directory also exist? Is there actually a /home/pi/test on the Pi4?
    – tink
    Commented Aug 19, 2021 at 19:03
  • @DavidC.Rankin: I tried: sudo mount.cifs //192.xxx.yyy.29/home/pi/test /home/pi/test -o vers=2.0,sec=ntlmssp,user=i,pass=xyz but I get the same error
    – Detlev
    Commented Aug 19, 2021 at 19:06
  • @tink: Yes, I have created a directory /home/pi/test on the Pi4.
    – Detlev
    Commented Aug 19, 2021 at 19:08

2 Answers 2

1

First DO NOT try to obscure Local IP addresses - they are private and inaccessible to anyone outside your network and just make your Question harder to read.

I have the following shares in my /etc/samba/smb.conf (I believe this may be standard to allow access to /home directories.)

[homes]
   comment = Home Directories
   browseable = yes

NOTE You mount a share not a directory. In your case this would be test

I can mount remote Pi with:-

sudo mount.cifs //MilliwaysPi4.local/pi /mnt/SDA2  -o user=pi

or

sudo mount.cifs //MilliwaysPi4.local/pi/bin  /mnt/SDA2  -o user=pi

NOTE Use a sensible mount point with root access, although you can in principle use any directory

NOTE # Testing the Share Access (on sharing server)
sudo smbclient -U ian //MilliwaysPi4/homes
sudo smbclient -U pi //MilliwaysPi4/pi

Then enter command at the smb: prompt

smb: \> ls
smb: \> quit
3
  • Thank you for your advise! I tried the smbclient command on my sharing Raspberry Pi and I get NT_STATUS_BAD_NETWORK_NAME. I assume there is something wrong with my Samba configuration. I will evaluate my smb.conf and see wehther I can find an error. I am just wondering why it works on my Windows PC?
    – Detlev
    Commented Aug 20, 2021 at 8:20
  • Thank you Millyways! I finally made it using the mount.cifs command you proposed. There was a misconfiguration in my Raspberry Pi 4. I reinstalled it and then it worked. Thanks a lot for your help!
    – Detlev
    Commented Aug 20, 2021 at 14:21
  • @Detlev if this answer solved your problem then please mark it as accepted (the green tick).
    – Darth Vader
    Commented Aug 20, 2021 at 15:38
1

As an alternative you may find the following script useful.

This uses nfs rather than samba, and requires nfs to be installed on the server sudo apt install nfs-kernel-server and /etc/exports to be configured. Mine contains the following to share homes:-

/home/pi *(rw,sync,no_subtree_check)

This could easily be adapted to mount any directory

#!/bin/bash
# Mount Remote Pi HOME directory
# remotePi [REMOTENAME [USERNAME]]
# Defaults to MilliwaysPi4 pi
# 2018-12-16

R_MOUNT='/mnt/remotePi'

# Check/create Mount Point
if [ ! -e $R_MOUNT ]; then
    sudo mkdir $R_MOUNT
fi

if [ $# -eq 0 ] ; then
    REMOTENAME='MilliwaysPi4'
else
    REMOTENAME=$1
fi

if [  $# -eq 2 ] ; then
    USERNAME=$2
else
    USERNAME='pi'
fi

# echo "USER" $USERNAME
REMOTENAME+=".local"
# echo $REMOTENAME
REMOTEDIR=$REMOTENAME
REMOTEDIR+=':/home/'
REMOTEDIR+=$USERNAME
REMOTEDIR+='/'
# echo $REMOTEDIR

if [ ! -z "$(ls -A $R_MOUNT)" ]; then
    sudo umount /mnt/remotePi
fi

sudo mount $REMOTEDIR /mnt/remotePi/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.