Unable to connect to mounted USB HDD via Samba

Having issues with your DietPi installation or found a bug? Post it here.
technovice
Posts: 6
Joined: Sat Nov 28, 2020 11:56 pm

Unable to connect to mounted USB HDD via Samba

Post by technovice »

Apologies if I've missed an existing thread with this question - I took a look but wasn't able to spot a solution.

I've recently swapped from Raspbian to DietPi so that I can use my old Pi Zero W as a simple usenet downloader. Using an older howtogeek tutorial, I've mounted an external USB hard drive in DietPi and am trying to get a Samba network share up and running. While the HTG tutorial has the external drive named as 'Backup' and the user 'backups', I've called both 'shares' on my setup.

However, while I can connect from my Windows 10 PC to the default DietPi folder share (i.e. \\DIETPI\dietpi\), and I can see my external drive in the Windows network folder (\\DIETPI\shares\), it's not letting me connect.

The error code that comes up (0x80070043) claims that 'the network name cannot be found', and when I diagnose the issue a second error message pops up: 'You don't have permission to access the share'.

Any ideas how to fix this problem?
User avatar
Joulinar
Posts: 3836
Joined: Sat Nov 16, 2019 12:49 am

Re: Unable to connect to mounted USB HDD via Samba

Post by Joulinar »

Hi,

thanks for your message. pls can you share your smb.conf file as well as lsblk -o name,fstype,label,size,ro,type,mountpoint
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
technovice
Posts: 6
Joined: Sat Nov 28, 2020 11:56 pm

Re: Unable to connect to mounted USB HDD via Samba

Post by technovice »

Sure, here's my smb.conf - I've added the [shares] section in, but the rest was there as default:

Code: Select all

[global]

        workgroup = WORKGROUP
        server string = %h server
        dns proxy = no
        log file = /var/log/samba/log.%m
        max log size = 1000
        syslog only = no
        syslog = 0

        panic action = /usr/share/samba/panic-action %d

        security = user
        encrypt passwords = true
        passdb backend = tdbsam
        obey pam restrictions = yes
        unix password sync = yes

        passwd program = /usr/bin/passwd %u
        passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
        pam password change = yes
        map to guest = bad user

        load printers = no
        printcap name = /dev/null
        disable spoolss = yes

[dietpi]
        comment = DietPi Share
        path = /mnt/dietpi_userdata
        browseable = yes
        create mask = 0664
        directory mask = 0775
        valid users = dietpi
        writeable = yes
        max connections = 2

[shares]
        comment = USBHDD
        path = /mnt/USBHDD/shares
        valid users = @users
        force group = users
        create mask = 0660
        directory mask = 0771
        read only = no
And the output of lsblk:

Code: Select all

NAME        FSTYPE LABEL   SIZE RO TYPE MOUNTPOINT
sda                        1.8T  0 disk
└─sda1      exfat  BACKUP  1.8T  0 part
mmcblk0                   59.5G  0 disk
├─mmcblk0p1 vfat   boot    256M  0 part /boot
└─mmcblk0p2 ext4   rootfs 59.2G  0 part /
User avatar
Joulinar
Posts: 3836
Joined: Sat Nov 16, 2019 12:49 am

Re: Unable to connect to mounted USB HDD via Samba

Post by Joulinar »

ok let me try to replicate your issue.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
technovice
Posts: 6
Joined: Sat Nov 28, 2020 11:56 pm

Re: Unable to connect to mounted USB HDD via Samba

Post by technovice »

Thanks Joulinar!
User avatar
Joulinar
Posts: 3836
Joined: Sat Nov 16, 2019 12:49 am

Re: Unable to connect to mounted USB HDD via Samba

Post by Joulinar »

Hi,

Ok I guess I found it. Is there a particular reason to set following value in your smb.conf file

Code: Select all

        valid users = @users
        force group = users
Because this will limit access to the share to user who are member of the group users. Usually on Debian this group is empty and not used as Debian systems use the private user group system by default (each user has their own group). Basically you would need to add all user who should have access to the group users.

However from security point of view this doesn't make any difference to have multiple user created and trying to separate the access because you are using exFAT as file system format on your HDD. exFAT, as an extension of FAT and not capable of storing discretionary access control metadata. This is why all the files on an exFAT volume appear to be 777 permissions (root user). ;)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
technovice
Posts: 6
Joined: Sat Nov 28, 2020 11:56 pm

Re: Unable to connect to mounted USB HDD via Samba

Post by technovice »

I did that because the instructions in the HTG tutorial had those values listed for Samba sharing in Raspbian, so I assumed that they would apply in DietPi as well.

Is that not the case? I assume if I need to add specific users, that I should add my 'shares' user there instead?

Thanks again for the help!
User avatar
Joulinar
Posts: 3836
Joined: Sat Nov 16, 2019 12:49 am

Re: Unable to connect to mounted USB HDD via Samba

Post by Joulinar »

If you don't need the dietpi share, just go to adjust this section. No need to create a 2nd share and you can stay with dietpi user.

Code: Select all

[dietpi]
        comment = DietPi Share
        path = /mnt/dietpi_userdata
        browseable = yes
        create mask = 0664
        directory mask = 0775
        valid users = dietpi
        writeable = yes
        max connections = 2
As well you can have a look to DietPi online docs https://dietpi.com/docs/software/file_s ... ile-server
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
technovice
Posts: 6
Joined: Sat Nov 28, 2020 11:56 pm

Re: Unable to connect to mounted USB HDD via Samba

Post by technovice »

Joulinar wrote: Tue Dec 01, 2020 12:45 am If you don't need the dietpi share, just go to adjust this section. No need to create a 2nd share and you can stay with dietpi user.
WIll using the DietPi share details already in there let me access the external hard drive though? It's a different path from the current one in there (i.e. /mnt/dietpi_userdata), so not sure if I need to change that to /mnt/USBHDD/shares or not?
technovice
Posts: 6
Joined: Sat Nov 28, 2020 11:56 pm

Re: Unable to connect to mounted USB HDD via Samba

Post by technovice »

Okay, still not connecting unfortunately.

I commented out the [shares] lines, changed the filepath to /mnt/USBHDD/shares, and also cleared all the existing network credentials on my W10 PC, but it's still telling me that 'Your user account doesn't have permission to access "dietpi"'
Post Reply