Hi,
I'm new to dietpi. I installed in on my Raspberry Pi 4. It works great. But I have a question about Samba/SMB server.
I choosed Samba server over FTP for a better integration with Windows and my Windows apps. But I have an issue :
I would like the base directory to be the root folder of my pi. I often need to access various folders such as /mnt, /home ....... I found on the wiki how to change the base directory for the samba share, but it doesn't work with root. I can only choose folders such as /mnt or /home as base folder. I would like to choose / . I can use this command found on the wiki :
sed -i '/path = /c\path = /Path/To/Directory' /etc/samba/smb.conf
dietpi-services restart
If I only put / in /Path/To/Directory, it doesn't work. I don't want to enter this command each time I want to switch between /mnt or /home. I would like to be on the root of these folders in samba.
How could I do that ? Thanks in advance for any answer. Any answer is welcome. Have a good day!
Samba file server - How can I set root folder as base directory ? Topic is solved
-
- Posts: 49
- Joined: Tue Apr 28, 2020 3:00 pm
Re: Samba file server - How can I set root folder as base directory ?
H,
that should be quite easy. Just edit the smb.conf file manually.
see attached. That's how it looks like 
that should be quite easy. Just edit the smb.conf file manually.
Code: Select all
nano /etc/samba/smb.conf
remove - path = /mnt/dietpi_userdata/
add + path = /
systemctl restart smbd.service

Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
-
- Posts: 49
- Joined: Tue Apr 28, 2020 3:00 pm
Re: Samba file server - How can I set root folder as base directory ?
It works perfectly, thanks ! That's exactly what I wanted to achieve.
But I have an issue : there is lots of folders I don't have the permissions to access like /root :

How can I manage the permissions for the SMB share ? How can I authorize this folder ?
Thanks in advance for your help. Have a good day !
But I have an issue : there is lots of folders I don't have the permissions to access like /root :

How can I manage the permissions for the SMB share ? How can I authorize this folder ?
Thanks in advance for your help. Have a good day !
Re: Samba file server - How can I set root folder as base directory ?
that's correct because you are going to login as user dietpi but the directory is owned by user root and only root can access it
If you really like to get access to this directory, you would need to login as user root. That would mean to allow root access to your system via SMB. Usually this is a security risk and should be avoided if possible. However it's something that can be archived as follow:
The password you are going to specify is valid for SMB access only. It could be different from the OS / SSH password you are using to login to your system.
It might be Windows is caching the old SMB access (with user dietpi) and it is not going to ask for new user/password. If this happen you might need to clean your share by using net use \\<yourIP>\dietpi /delete for example, if dietpi was still the name of your SMB share.
Code: Select all
drwx------ 5 root root 4096 Apr 29 15:58 root
Code: Select all
nano /etc/samba/smb.conf
remove - valid users = dietpi
add + valid users = root
smbpasswd -a root
systemctl restart smbd.service
It might be Windows is caching the old SMB access (with user dietpi) and it is not going to ask for new user/password. If this happen you might need to clean your share by using net use \\<yourIP>\dietpi /delete for example, if dietpi was still the name of your SMB share.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
-
- Posts: 49
- Joined: Tue Apr 28, 2020 3:00 pm
Re: Samba file server - How can I set root folder as base directory ?
Ok thanks a lot for all your help.
I use my pi to run a minecraft server, and a jellyfin media server. So the only folders I need to access through SMB are
/root/minecraft
and
/mnt
Maybe I could minimize the security risk by allowing SMB server to access only these folders (not whole /root, only /root/minecraft)
How could I do that ?
And thanks again for your help ! Have a good day
I use my pi to run a minecraft server, and a jellyfin media server. So the only folders I need to access through SMB are
/root/minecraft
and
/mnt
Maybe I could minimize the security risk by allowing SMB server to access only these folders (not whole /root, only /root/minecraft)
How could I do that ?
And thanks again for your help ! Have a good day
Re: Samba file server - How can I set root folder as base directory ?
if you need to access these 2 directories only, you would need to create 2 samba shares. Lets edit your smb.conf again.
remove the whole [dietpi] section at the end and replace it as follow.
don't forget to restart your samba server
Code: Select all
nano /etc/samba/smb.conf
Code: Select all
[minecraft]
comment = Minecraft Share
path = /root/minecraft
browseable = yes
create mask = 0775
directory mask = 0775
valid users = root
writeable = yes
max connections = 2
[mnt]
comment = Mount Share
path = /mnt
browseable = yes
create mask = 0775
directory mask = 0775
valid users = root
writeable = yes
max connections = 2
Code: Select all
systemctl restart smbd.service
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
-
- Posts: 49
- Joined: Tue Apr 28, 2020 3:00 pm
Re: Samba file server - How can I set root folder as base directory ?
Thanks you so much ! Everything is perfect now. Have a good day !!!
Re: Samba file server - How can I set root folder as base directory ?
Your welcome
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team