Intermittent error with permissions in dataroot

Intermittent error with permissions in dataroot

by Julian Pool -
Number of replies: 6

We are seeing issues where we suddenly see the error:

"Can not create local file pool directories, please verify permissions in dataroot."

This renders any user unable to access any data on the site, and any images we've uploaded are also not shown as can't be read from the system. As soon as we reboot the box it comes back up and everything works as normal. The issue appears to occur randomly. It has happened a couple of times in some days, over the past seven days we've not see the issue at all, and then this morning it occurred.

Any ideas as to what might cause this on an intermittent basis?


----

Moodle version: 3.1.6

OS: Ubuntu 14.04


Thanks,

J

Average of ratings: -
In reply to Julian Pool

Re: Intermittent error with permissions in dataroot

by Jamie Kramer -

Do you know if your Moodle data directory is mounted from a network file system? Or is it running from a local storage volume? Some times things can go awry with network filesystems, and I think it might be good to know which one you are using.

You might need to check and verify that the permissions in the Moodle data directory are set correctly, or even reset the permissions on the Moodle data directory as a baseline first step. The steps to do this can vary depending on your setup.

In you Moodle config.php the dataroot setting shows the directory path for Moodle data directory. Lets say it is set to /mnt/data/moodledata (as an example)

On Linux you can look at the permissions for this directory and contents:

ls -la /mnt/data/moodledata

Does the user and group ownership look correct for your implementation? (It might be www-data for user and group on Ubuntu, but it varies depending on setup)

Perhaps some files or folders nested deeper in the data directory do not have correct ownership. This is where you could proactively set permissions on the data directory and all sub-files/folders recursively with the chown command. You would need to make sure that the user/group you set as owner matches the server user under which PHP is running. On Ubuntu this is often www-data by default, but may not be the case for your setup. As an example, here is how you could set permissions for www-data user/group on Moodle data directory (using example /mnt/data/moodledata path)

chown -R www-data:www-data /mnt/data/moodledata

If permissions are correct and the issue still occurs, I might suspect a server file-system type of issue.

In reply to Jamie Kramer

Re: Intermittent error with permissions in dataroot

by Julian Pool -

Thanks Jamie.

Our dataroot folder is configured to: /var/moodledata so is on the local file system.

All permissions appear correct, as all folders and files have www-data as the User and most as the Group. There are a few folders that although they have www-data as the User, have the local ubuntu user account as the Group. Maybe this is causing the problem? - Although as I said, it's not a permanent issue. It is fine today and everything seems to work. It is just occasionally we'll see the error.

I guess it must be due to permissions somewhere as the error indicates it, but it's just trying to identify why it randomly goes, and when you reboot it the error clears. Could it be anything to do with the Database, as that sits on a separate server, or is this error specific to the moodledata directory on the local server?

In reply to Julian Pool

Re: Intermittent error with permissions in dataroot

by Jamie Kramer -

Hi Julian.

local file system: Well at least that crosses one thing off the list, since network file systems can sometimes introduce some inconsistent behaviors.

Permissions: Since all permissions appear correct, I am now wondering if you by chance did a find command on the dataroot to find files or directories that aren't owned by www-data user. The group should not matter if the user ownership is correct. Perhaps this is what you already did to confirm the user owner, but if not, you might give it a try*:

find /var/moodledata/ \! -user www-data -print

That find command should find all files and directories that aren't owned by www-data.

Next, you might look for files and folders that are not readable or writable by www-data. I think this command might do*:

find /var/moodledata/ \! -perm -u+w

*Note: you might need to run those with sudo.

The other idea I have is to review your config.php and see if you are using alternate directories for temp or cache. By default, those directories go into the dataroot. However, in config.php you can override that and set separate directories. If you happen to be using a different path for temp, cache, or localcache directories, then maybe have a look at the permissions on those directories too. You might need to use the find commands like above.

Could it be anything to do with the Database: No I do not think this has anything to do with the database at all.

If those find commands turn nothing up then I begin to suspect other filesystem problems, though not sure what that would be right now (especially since you are on local filesystem). Would be curious to know your Linux distribution/version, and what filesystem is being used.



Average of ratings: Useful (1)
In reply to Jamie Kramer

Re: Intermittent error with permissions in dataroot

by Julian Pool -

Okay "find /var/moodledata/ \! -perm -u+w" came up blank, so that's ruled that out. But the first command, "find /var/moodledata/ \! -user www-data -print", brought back 154 files and folders not owned by www-data. They all sat within the below areas and are all owned by root.


/var/moodledata/filedir

/var/moodledata/lock

/var/moodledata/cache/cachestore_file


Is it possible when these resources are being accessed it throws the error? I will look at resolving the permissions on them and see if that helps.


Thanks for all your help so far.

In reply to Julian Pool

Re: Intermittent error with permissions in dataroot

by Jamie Kramer -

I am pretty certain that you've found the issue then with the first find command. The files listed from that command, being owned by root, are most certainly going to cause the original error you posted. I think once you set owner, recursively, for /var/moodledata , then you should be all set.

Something like:

chown -R www-data /var/moodledata

This situation with root ownership of files in the Moodle dataroot directory is often caused when someone has executed a Moodle cli (command line) utility as root instead of properly switching user to the web server user.

I think you should be all set once you set the files to be owned by the www-data user.

A note for any others that this thread might eventually help... note that the www-data user is not *always* going to be the correct user for ownership of Moodle data files. The correct users depends on some factors, such as which Linux distribution you are using and whether or not you are using the "default" webserver/php setup.

In reply to Jamie Kramer

Re: Intermittent error with permissions in dataroot

by Julian Pool -

Thanks Jamie. I'll see how this goes.

Thanks for taking the time to look into this for me.