Nextcloud version (eg, 29.0.5): 29.0.6
Operating system and version (eg, Ubuntu 24.04): Ubuntu 24.04.1
Apache or nginx version (eg, Apache 2.4.25): replace me
PHP version (eg, 8.3): replace me
The issue you are facing:
I am running this in an Ubuntu VM in Unraid. I have 2 virtual drives, one for nextcloud and another for data. I have been trying to change my data directory to /mnt/data, which is mounted on boot via fstab to sda1. When I tried to change ‘datadirectory’ => ‘/var/snap/nextcloud/common/nextcloud/data’, to ‘datadirectory’ => ‘/mnt/data’, I would continuously get an error.
I tried changing permissions on the /mnt/data folder from root:root to www-data:www-data using the command “chown -R www-data:www-data /mnt/data”. I also used this command: “chmod 770 /mnt/data” Unfortunately, neither of those solved the issue, and now I can no longer cd /mnt/data from an SSH session as I get an access denied message. Also, within nextcloud itself (when I go back to the original default data directory in config.php so I can login again), I can no longer write a file to my /mnt/data share, which is mounted as Local storage within the External Storage feature. Am I making any sense? I know enough about Linux to be dangerous, as is probably apparent.
My goal is simply to have nextcloud default to storing data on in my /mnt/data folder on my 2TB data drive (sda1) instead of on my system drive, which has much less space. I have seen a lot of people with this issue, but solutions seem to vary depending on whether nextcloud is in a docker, running via a snap (which is my setup) or some other way. Or at least I can’t find the solution to my particular problem. So, anyone know what I did wrong here, and what I need to do to recover from my mess making and accomplish my objective? Thanks so much.
I don’t think I have the answer but this might help.
cd via ssh: If you switch user to root you should be able to go anywere. (and of-course break anything too) sudo su
In any way you do it, Nextcloud’s files and data will need to be owned by www-data but it might simplify your setup if you symlink the default directory to the new location rather than trying to change the data directory.
(Someone please correct me if that for some reason is not a good idea)
@Plus5 - thanks so much for the attempt to help and the suggestions. I was able to do sudo su and get root, which is good, and I understand I need to be careful with that. I did a ```
chown -R www-data:www-data /mnt/data, but it didn’t seem to help any. Am I using that command incorrectly? When I look at my /mnt/data directory and do an ls -la, I get this:
Is that normal? I tried to run these commands:
[quote=“KarlF12, post:4, topic:150657”]
find nextcloud/ -type d -exec chmod 750 {} ;
find nextcloud/ -type f -exec chmod 640 {} ;
but they error out, reporting an insufficient argument for -exec. No idea why. Also, are those commands correct for my setup, or do I need to put my /mnt/data folder in that command somewhere somehow? Lastly, what do you mean by “symlink the default directory to the new location rather than trying to change the data directory”? How do I do that? Sigh… Linux and nextcloud can be maddening at times. Nevertheless, thanks for trying to help me out.
But since you are modifying the data directory I think you want to modify those commands to
cd /mnt
chown -R www-data:www-data data
find data/ -type d -exec chmod 750 {} \;
find data/ -type f -exec chmod 640 {} \;
In any case you would need to copy/move your existing data directory to /mnt/data before you would be ready to run those commands.
I believe that in your case, since all the files are on the same machine you should be able to copy (less risk of data loss if you copy instead of move) your existing data directory with
You will probably want to clean out everything in /mnt/data before you copy your nextcloud data into it.
I don’t think you will need to run the find command at all since your permission should stay intact from the existing data directory. You will need to change the owner though since cp changes the owner to the user making the copy. In theory it would be possible to copy the data as www-data but using changing the owner afterward should have the same result with less chances of errors.
If you have errors please post the complete terminal output like you did above. Being able to see what command you were trying to run as well as the current directory is very helpful.
Thanks so much! Great to have info about what needs to be replaced to ensure proper syntax. Ok, so did everything you suggested, but still having some issues. Nextcloud runs fine, but… when I upload a file to my default file area (wherever it is that you wind up when you click on the “Files” icon at the top left of the NC main screen) the upload completes without issue, however, the files are not going into my /mnt/data folder (confirmed through an SSH session to that folder and an “ls” command). I tried changing the “‘datadirectory’ => ‘/var/snap/nextcloud/common/nextcloud/data’,” line in config.php to “‘datadirectory’ => ‘/mnt/data’,” but that still causes NC not to run and generates an error message about my default data directory being incorrect, and needing an .ocdata file in it, etc. (sorry, forgot to screenshot that one, but can go back and replicate it if you want to see it). So, I switched that setting back to “‘datadirectory’ => ‘/var/snap/nextcloud/common/nextcloud/data’,” and things work again, except for an inability to upload any files to the “Data” folder in my default area, which I believe is my /mnt/data folder. Also, NC does not see any files in this folder, though there are files in my /mnt/data folder as confirmed through an SSH session and ls command. My external storage is setup like this:
and when I try to upload files to what I believe to be that folder (a “Data” folder in my default NC area) it freezes there and never completes, which again leads me to believe that NC still cannot write to that folder, and since it displays no files in the folder even though I know files are there, it probably can’t read from it either. It seems like that folder is only accessible to root, as I can only access it in an SSH session when using “Sudo su” and assuming the root identity. Here are the current permissions on my /mnt/data folder:
Is it a problem that “…” is showing as root when everything else is www-data, which is what I think it needs to be for NC to access it properly? I think I’m getting closer, but any ideas? Thanks for your patience with me. You probably feel like I feel when helping my mom with her computer issues ;-)) Thanks again!
Directory .. is the parent directory so /mnt. Those permissions should not be a problem since you are not writing to /mnt but rather into the current directory . or /mnt/data and that is writable by www-data.
External storage is not the same as the data directory.
Are you trying to mount /mnt/data as external storage or are you wanting to move your primary storage to /mnt/data? I have no idea what would happen if you point both your data directory (set in config.php) and your external storage to the same location.
I believe the root of the file-system as shown by the webui is the same as the ‘datadirectory’ value in config.php.
Funny you ask this question. All I want to do is provide access to a sizable amount of cloud storage to various members of my family with unique logins and keep their folders and access separate, except for a central “Family” folder where all share it and anyone can dump files into it and access someone else’s content that they want to share in bulk (i.e. without having to send separate sharing links when there are many files (like photos) to share). In other words, each person’s stuff is separate unless you dump stuff in the “Family” folder, and then everyone can see it, access it, copy it, etc.
I first tried mounting an SMB share, but had issues installing the SMB client properly. So, I tried the “group folders” feature/app but determined that it was storing data on my smaller system drive, so that was no good. Online research led to the suggestion of mounting a folder as “Local Storage” using the “External Storage” functionality, and locating it on a larger drive and then changing the default storage location to that folder so the group folders would store data there. However, try as I might to correctly change the “‘datadirectory’ => ‘/var/snap/nextcloud/common/nextcloud/data’,” to /mnt/data in the config.php it always generated an error upon NC login, so I needed to change it back to the default.
So, I stopped trying to do the above and was hoping just to get the permissions right, but can’t seem to do that either.
All this to say… the best result would probably be using group folders, but being able to store those folders on my larger drive and then managing access to those group folders via groups and user permissions in NC. Any idea how I untangle this NC mess and accomplish what I want to do?
Thanks again for offering suggestions - you’re the only one who’s been interested so far, so maybe no one else has this desired use case? In any event, I really appreciate the time and effort.
If you think the issue is with file permissions, try performing file actions from the terminal as www-data. For example, sudo -u www-data mkdir test. That should give you more specific error messages if the issue is with file permissions.
If you are not able to set the data directory to the mount location, you could try mounting the drive at your data directory location. You could also try creating a symblink in place of your current data directory that points to the the new one.
My experience with Nextcloud’s external storage feature makes me want to completely avoid it.
I understand, and I’m with you on the external storage feature - doesn’t seem intuitive or to work as expected. Then again, when you only know enough to be dangerous, well, I am, and I probably shouldn’t be denigrating something I don’t know how to use well. I might just reinstall the whole damn system on my 2TB drive just to avoid these issues, but that also feels like I’m waving the white flag instead of learning, understanding, and solving. In any event, thanks for your attempts to help. I do appreciate it.