Samba - how change path to external HDD drive ?

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
misho
Posts: 11
Joined: Sat Nov 13, 2021 12:24 pm

Samba - how change path to external HDD drive ?

Post by misho »

Hello guys,

I am new to linux and dietpi, i would like to help with following problem,

I have installed samba via dietpi-software, i can access samba with username "dietpi" + pass. But I would like to change the path to my external hard drive.

I have mounted my ext drive with:

Code: Select all

sudo mount /dev/sda1 /media/SSD
And i have also changed path in samba config with:

Code: Select all

sed -i '/path = /c\path = /media/SSD' /etc/samba/smb.conf
systemctl restart nmbd smbd
But I can't access samba anymore. Thanks for your help. What am I missing? THANKS 8)

ls /media/SSD is showing folders, and i can also access them. (I am using also Nextcloud)
User avatar
Joulinar
Posts: 6441
Joined: Sat Nov 16, 2019 12:49 am

Re: Samba - how change path to external HDD drive ?

Post by Joulinar »

Pls share following

Code: Select all

ls -la /media/SSD
cat /etc/samba/smb.conf
lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid
systemctl status nmbd smbd
ss -tulpn | grep LISTEN
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
misho
Posts: 11
Joined: Sat Nov 13, 2021 12:24 pm

Re: Samba - how change path to external HDD drive ?

Post by misho »

Code: Select all

root@DietPi:~# la -la /media/SSD
-bash: la: command not found
root@DietPi:~# la -la /media/SSD
cat /etc/samba/smb.conf
lsblk -o name,fstype,label,size,ro,type,mountpoint,partuuid,uuid
systemctl status nmbd smbd
ss -tulpn | grep LISTEN
-bash: la: command not found
[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 = 8
NAME FSTYPE LABEL   SIZE RO TYPE MOUNTPOINT PARTUUID                             UUID
sda               111.8G  0 disk                                                 
└─sda1
     ext4   ssd   111.8G  0 part /media/SSD c1c2efc0-c5dc-01d4-e073-e160ee62ea00 bce71f79-ab89-4d50-8ba7-d265c6ce4c0b
mmcblk0
│                  29.5G  0 disk                                                 
└─mmcblk0p1
     ext4          29.4G  0 part /          89086adf-01                          8724794f-4966-4eeb-9e56-4eab78d3c318
● nmbd.service - Samba NMB Daemon
     Loaded: loaded (/lib/systemd/system/nmbd.service; disabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/nmbd.service.d
             └─dietpi-services_edit.conf
     Active: active (running) since Sat 2021-11-13 11:09:36 GMT; 1h 34min ago
       Docs: man:nmbd(8)
             man:samba(7)
             man:smb.conf(5)
   Main PID: 8701 (nmbd)
     Status: "nmbd: ready to serve connections..."
      Tasks: 1 (limit: 2067)
     Memory: 2.7M
        CPU: 491ms
     CGroup: /system.slice/nmbd.service
             └─8701 /usr/sbin/nmbd --foreground --no-process-group

Nov 13 11:09:35 DietPi systemd[1]: Starting Samba NMB Daemon...
Nov 13 11:09:36 DietPi systemd[1]: Started Samba NMB Daemon.

● smbd.service - Samba SMB Daemon
     Loaded: loaded (/lib/systemd/system/smbd.service; disabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/smbd.service.d
             └─dietpi-services_edit.conf
     Active: active (running) since Sat 2021-11-13 11:09:36 GMT; 1h 34min ago
       Docs: man:smbd(8)
             man:samba(7)
             man:smb.conf(5)
    Process: 8702 ExecStartPre=/usr/share/samba/update-apparmor-samba-profile (code=exited, status=0/SUCCESS)
   Main PID: 8711 (smbd)
     Status: "smbd: ready to serve connections..."
      Tasks: 3 (limit: 2067)
     Memory: 4.6M
        CPU: 1.638s
     CGroup: /system.slice/smbd.service
             ├─8711 /usr/sbin/smbd --foreground --no-process-group
             ├─8713 /usr/sbin/smbd --foreground --no-process-group
             └─8714 /usr/sbin/smbd --foreground --no-process-group

Nov 13 11:11:51 DietPi smbd[8715]: pam_unix(samba:session): session closed for user dietpi
Nov 13 11:11:54 DietPi smbd[8858]: pam_unix(samba:session): session opened for user dietpi(uid=1001) by (uid=0)
Nov 13 11:16:11 DietPi smbd[8858]: pam_unix(samba:session): session closed for user dietpi
Nov 13 11:18:28 DietPi smbd[9548]: pam_unix(samba:session): session opened for user dietpi(uid=1001) by (uid=0)
Nov 13 11:22:48 DietPi smbd[9548]: pam_unix(samba:session): session closed for user dietpi
Nov 13 11:39:32 DietPi smbd[10948]: pam_unix(samba:session): session opened for user dietpi(uid=1001) by (uid=0)
Nov 13 11:39:48 DietPi smbd[10948]: pam_unix(samba:session): session closed for user dietpi
Nov 13 11:42:31 DietPi smbd[10951]: pam_unix(samba:session): session closed for user nobody
Nov 13 11:42:36 DietPi smbd[10961]: pam_unix(samba:session): session opened for user dietpi(uid=1001) by (uid=0)
Nov 13 11:48:42 DietPi smbd[10961]: pam_unix(samba:session): session closed for user dietpi
tcp   LISTEN 0      50           0.0.0.0:445       0.0.0.0:*    users:(("smbd",pid=8711,fd=44))       
tcp   LISTEN 0      80         127.0.0.1:3306      0.0.0.0:*    users:(("mariadbd",pid=7754,fd=19))   
tcp   LISTEN 0      50           0.0.0.0:139       0.0.0.0:*    users:(("smbd",pid=8711,fd=45))       
tcp   LISTEN 0      511        127.0.0.1:6379      0.0.0.0:*    users:(("redis-server",pid=7690,fd=7))
tcp   LISTEN 0      1024         0.0.0.0:80        0.0.0.0:*    users:(("lighttpd",pid=7868,fd=4))    
tcp   LISTEN 0      1000         0.0.0.0:22        0.0.0.0:*    users:(("dropbear",pid=378,fd=4))     
tcp   LISTEN 0      50              [::]:445          [::]:*    users:(("smbd",pid=8711,fd=42))       
tcp   LISTEN 0      511            [::1]:6379         [::]:*    users:(("redis-server",pid=7690,fd=8))
tcp   LISTEN 0      50              [::]:139          [::]:*    users:(("smbd",pid=8711,fd=43))       
tcp   LISTEN 0      1024            [::]:80           [::]:*    users:(("lighttpd",pid=7868,fd=5))    
tcp   LISTEN 0      128                *:21              *:*    users:(("proftpd",pid=3203,fd=0))     
tcp   LISTEN 0      1000            [::]:22           [::]:*    users:(("dropbear",pid=378,fd=5))     

ls -ls /media/SSD:

Code: Select all

root@DietPi:~# ls -ls /media/SSD
total 32
 4 drwxr-x--- 3 www-data www-data  4096 Nov  8 12:12  AndroidBackupy
 4 drwxr-x--- 3 www-data www-data  4096 Nov  8 07:17 'Fotky a videa'
16 -rwxr-x--- 1 www-data www-data 12337 Nov  2 14:10  test.ods
 4 drwxr-x--- 4 www-data www-data  4096 Nov 13 07:19  ISF
 4 -rw-r--r-- 1 www-data www-data     1 Nov 12 13:16  Readme.md

User avatar
Joulinar
Posts: 6441
Joined: Sat Nov 16, 2019 12:49 am

Re: Samba - how change path to external HDD drive ?

Post by Joulinar »

Sorry there was a typo on the first command (corrected now)

But samba seems running fine. Services are active and Samba is listen on correct port. Just your samba configuration file is still pointing to the default DietPi user data directory.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
misho
Posts: 11
Joined: Sat Nov 13, 2021 12:24 pm

Re: Samba - how change path to external HDD drive ?

Post by misho »

Yes, and that's what i am asking for. How can i change the directory to /media/SSD when i logged in with user "dietpi". Thanks

I wrote, that i can connect to samba server without issues, i just need to change the folder.

Code: Select all

root@DietPi:~# ls -la /media/SSD
total 40
drwxr-x--- 5 www-data www-data  4096 Nov 13 10:42  .
drwxr-xr-x 3 root     root      4096 Nov 12 12:12  ..
drwxr-x--- 3 www-data www-data  4096 Nov  8 12:12  AndroidBackupy
drwxr-x--- 3 www-data www-data  4096 Nov  8 07:17 'Fotky a videa'
-rwxr-x--- 1 www-data www-data 12337 Nov  2 14:10  test.ods
drwxr-x--- 4 www-data www-data  4096 Nov 13 07:19  ISF
-rw-r--r-- 1 www-data www-data     1 Nov 12 13:16  Readme.md

User avatar
Joulinar
Posts: 6441
Joined: Sat Nov 16, 2019 12:49 am

Re: Samba - how change path to external HDD drive ?

Post by Joulinar »

Usually this command should do

Code: Select all

sed -i '/path = /c\path = /media/SSD' /etc/samba/smb.conf
systemctl restart nmbd smbd
Is it not working in you case?

If not you can change path variable manually

Code: Select all

nano /etc/samba/smb.conf
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
misho
Posts: 11
Joined: Sat Nov 13, 2021 12:24 pm

Re: Samba - how change path to external HDD drive ?

Post by misho »

Did you read my first message? I have tried this :). Path is changed.

But i can't access folder / smb share after i change the path. There is some problem with permissions maybe?

The Solid Explorer is saying "Access denied" when i click on Dietpi folder. Thanks
misho
Posts: 11
Joined: Sat Nov 13, 2021 12:24 pm

Re: Samba - how change path to external HDD drive ?

Post by misho »

partically solved, i can see the folder, but can't write / copy files on drive

Code: Select all

sudo chmod -R 0755 /media/SSD
User avatar
Joulinar
Posts: 6441
Joined: Sat Nov 16, 2019 12:49 am

Re: Samba - how change path to external HDD drive ?

Post by Joulinar »

A little bit expected as all folder on SSD are owned by user www-data? Hence user dietpi has no write access ;)

You could add user dietpi into web server group www-data. As well write permission would be needed on group level.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 3514
Joined: Sat Nov 18, 2017 6:21 pm

Re: Samba - how change path to external HDD drive ?

Post by MichaIng »

Or change the owner to dietpi, as it doesn't look like what you want to serve via web server?
Post Reply