Can't create or write into the data directory / Can't write into config directory! / Data directory (/mnt/data) is invalid

Problem

You’re getting one of the following error message:

  • Can’t create or write into the data directory
  • Can’t write into config directory!
  • Data directory (/mnt/data) is invalid (/mnt/data is an example here)

Solutions

The messages basically means that ownCloud can’t access and write into the mentioned directories (as the messages are telling). There are a few issues which are showing up quite often:

Missing permissions

You have permission issues that the users which is running your webserver has no access to this folders. If you’re on e.g. Ubuntu/Debian this can be checked by running the following command:

sudo -u www-data ls -la /path/to/folder

this command should return a list of files / folders instead of a “Permission denied” message.

If the command is failing you need to make sure to setup the correct permission. How to setup the correct permissions needed are described here:

https://doc.owncloud.org/server/9.1/admin_manual/installation/installation_wizard.html#setting-strong-directory-permissions

open_basedir

Within PHP it is possible to configure a open_basedir to restrict access of PHP to specific files and folders. If this setting doesn’t contain the folder where ownCloud needs to write into it will fail. Please see the PHP manual available here how to configure this correctly:

https://secure.php.net/manual/en/ini.core.php#ini.open-basedir

SELinux

On systems running SELinux a correctly configured policy is needed. The ownCloud documentation available here provides basic infos for this:

https://doc.owncloud.org/server/9.1/admin_manual/installation/selinux_configuration.html

If you need further help with SELinux please contact a support community dedicated to your used linux distro as SELinux is a quite complex topic.

Wrong mount permissions

If ownCloud itself or one of the mentioned directories are placed on an external hard disc which is mounted automatically or manually into your system it might be possible that the permissions where setup incorrectly during mount time. This happens especially if the external hard disc is formatted with e.g. NTFS.

It is important that the user running your webserver (e.g. www-data, apache or httpd) has full read and write permissions to that mount point. As giving linux basics are out of the scope of this forums please have a look at tutorials / answers like:

etc.

An example /etc/fstab line which might also work on your system could be:

//192.168.0.1/ownCloud /mnt/owncloud cifs credentials=/home/username/.smbcredowncloud,rw,uid=33,gid=33,dir_mode=0770,iocharset=utf8,sec=ntlm 0 0