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:
sudo mount /dev/sda1 /media/SSD
And i have also changed path in samba config with:
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.
Thank you guys for your replies, sorry i was out of my home,… nowi will take a look on it.
Can you please tell me how can i add the user “dietpi” into web server group www-data ? Thanks
/edit: I have tried this command, is that right? Added dietpi user to www-data group
root@DietPi:~# sudo adduser dietpi www-data
Adding user `dietpi' to group `www-data' ...
Adding user dietpi to group www-data
Done.
root@DietPi:~# id dietpi
uid=1000(dietpi) gid=1000(dietpi) groups=1000(dietpi),33(www-data)
and reboot, but still can’t write to /mnt/SSD via SMB. (Permissions denied) With dietpi user logged in
You cannot write there because you do not grant members of the www-data group write permissions, only the www-data user:
drwxr-x---
This means a directory “d” with read+write+execute permissions for the owner (rwx), but only read+execute permissions for group members (r-x) and no permissions for anyone else (—).
The question is why is a media drive owned by the webserver user? Doesn’t make it sense to change this to be owned by the dietpi user? Else:
chmod -R g+rw /media/SSD
So you add read+write permissions for group members.
I have installed nextcloud. Maybe that’s the reason? I was just following tutorials
I don’t know what will happen, if i change it to dietpi user. I Think it will not be possible to use nextcloud app / web to write and use /media/SSD, or am I wrong ?
So what do you recommend to me? THANKS !
/edit: I have tried to
sudo chown -R dietpi:dietpi /mnt/SSD
and as i said, can’t write/edit anything in nextcloud in that folder /mnt/SSD
I am sorry that i have not mentioned this information at the begining. (NEXTCLOUD installed)
You use Nextcloud to write to that directory? Yes that is a good explanation. However, note that the Nextcloud data directory is not meant to be touched directly but only through Nextcloud. Otherwise, if you now create new files or change them through Samba, Nextcloud doesn’t know about it and has the old information stored in its file index database. So you will have more and more missing, false and obsolete information in Nextcloud. There are storage extensions available for Nextcloud, at least for adding a remote Samba share, but not sure whether there is one which provides Nextcloud data through a local Samba server natively. But webdav is what Nextcloud natively uses, so webdav clients can be used as alternative, and of course the official Nextcloud clients.
So in short: Do not share the same data via Nextcloud and Samba concurrently. You should be able to find Nextcloud compatible clients for all thinkable platforms.
Maybe i know exactly what are you trying to tell me… And Iunderstood
My goal was that i will use one external SSD for Nextcloud data and this drive will be also shared via SMB. Nevermind…
And what about creating 2nd folder /media/SSD/SMB with sudo chown -R dietpi:dietpi /media/SSD/SMB. Is that bad / wrong idea? I would rather ask, then do some mistake / security etc…
Sharing it as read-only data btw is not an issue, but whether this makes sense instead of native Nextcloud client or webdav client is another question.
Ah indeed the whole drive doesn’t seem to be the Nextcloud data directory, as this contains some specific files and directories, most importantly the .ocdata file as marker, like here:
# ls -Al /mnt/sda/ncdata/
total 44K
-rw------- 1 www-data www-data 542 Nov 20 15:19 .htaccess
-rw------- 1 www-data www-data 0 Nov 20 15:19 .ocdata
drwx------ 7 www-data www-data 4.0K Sep 7 2019 XXXXX
drwx------ 8 www-data www-data 4.0K Aug 11 2019 Micha
drwx------ 12 www-data www-data 4.0K Nov 15 18:53 appdata_XXXXX
drwx------ 2 www-data www-data 4.0K Dec 16 2020 files_external
-rw------- 1 www-data www-data 0 Nov 20 15:19 index.html
-rw-r----- 1 www-data www-data 1.8K Nov 20 15:42 nextcloud.log
drwx------ 2 www-data www-data 4.0K Nov 19 17:02 tmp
drwx------ 4 www-data www-data 4.0K Nov 19 00:18 updater-XXXXX
-rw------- 1 www-data www-data 0 Nov 20 15:42 updater.log
So basically it then makes sense to have only the Nextcloud data (sub) directory itself owned by www-data and either everything else (on the drive) or a dedicated sub directory for Samba owned by “dietpi”. So depending on your needs to can either share a dedicated sub directory via Samba or the whole drive, but with read-only access to the Nextcloud data directory.
1 SSD Drive mounted as /mnt/SSD, with 2x FOLDERS: NEXTCLOUD and NAS. Nextcloud folder with www-data group premissions, and NAS with dietpi user permissions.
And SSD Drive /mnt/SSD, will have rootpermissions, right? Or dietpi ?
Yes that will work very fine and clean. If only /mnt/SSD/NAS should be writable for Samba, then it makes sense to keep the /mnt/SSD owned by root. So you can add other sub directory for other purposes and have each service cleanly permitted to write to its own intended directory only.
Thanks, i have done it, but i can’t figure why SMB is not working, i can’t even see the folders (Premissions problem)
If I set root permissions on /mnt/SSD , the nextcloud isn’t working, even when i set www-data permissions on the folder mnt/SSD/NEXTCLOUD…
So i did following,
sudo chown -R www-data:www-data /mnt/SSD/
sudo chown -R dietpi:dietpi /mnt/SSD/NAS