Ncp-scan shows "Home storage for user not writable"

Hello, for several days the content of my server has not been identical to the content of the web interface, as well as the nextcloud client, whether on my android smartphone or on my computer.

I have searched and when I do an ncp-scan, I get the following message:

"Home storage for user xxx not writable 
Make sure you're running the scan command only as the user the web server runs as"

I saw that on the forum some people solved a similar problem by snooping in the occ ldap database but I am a simple user and I don’t understand anything.

I would like to precise that the owner of the user xxx/files/ is not www-data but xxx.
xxx belong to www-data group and I have made a chmod 775, thus xxx AND www-data shall be able to read-write-execute :

Please, what should I do step-by-step to allow my files folder to be rescanned?
Thank you.

Hello, any news please ? I have tried to fix permission with nc-fix-permission, but while the fix-permission is successful, I still can’t scan user folder with still the same error message :

Home storage for user xxx not writable 
Make sure you're running the scan command only as the user the web server runs as

www-data should really be the owner, not just group.

The www-data group has r-x,
The owner has rwx
for all the folders below /media/xxxxxx/files/

In general, I would strongly advise against meddling with NC’s files ownership, it can compromise the security of your server. Why do you want or need to?

That said; it’s a free world. It’s your server and files.
You could try chmod with -R (recursive)

1 Like

Hello and thank you for your advise.
The reason why I have changed permissions is because use a cron.daily script in /etc/cron so I need to give to the server user rwx in /media/xxxxxx/files/
this is why I have changed permissions as the following :

  • server user as the owner
  • and www-data as group
  • and server user as member of www-data group,
    … but it seems this doesn’t work.

Now, as you can see, I have used nc-fix-permissions and now I have www-data as owner and group
2019-09-01 :
Note that nc-fix-permissions does not change permissions for files_versions folder.

Anyway, ncp-scan still show the same error message. I really don’t understand. Could files_versions folder be the reason ? Thank you.

Hi prog-amateur,

you say, you changed the permission because you are using a cron.daily script? What is this script doing?

If I am not wrong, you could have just added the server user to the group www-data and left the permission as it was. On the other hand, you can setup cron jobs to run as a specific user, so you could have setup a cron job for the user www-data. This way the user www-data would be the owner of the data and could have run the required cron job.

1 Like

Tampering with the permissions within the data folder is asking for trouble. You should heed CFelix’s advice if you really must give access to another user.

I would start by disabling the Cron job, setting the permissions back as they were, and running occ files:scan --all

1 Like

@CFelix : thank you very much for your help. My cron.daily script is an update script for a program (so each day this program is up to date in my server), but I also intend to make a rsync script to backup my data every day in an external disk.

@KarlF12 : thank you too, I intend to proceed as you said, but shall I use occ files:scan --all or ncp-scan as I am in NextcloudPi version ? Thank you.

Sorry, I run the Docker version, so I am a little unfamiliar with the custom scripts used in the RPi version.

I’m a little unclear why you need to modify permissions for the tasks you mentioned. You could just run the backup as the www user, or as root.

For the program update, I would suggest using a folder that doesn’t belong to Nextcloud, and then set it up as external storage. This avoids the need to run the file scan at all or change any permissions inside the data folder.

Thank you, after changing permission of the cron job (to www-data) and fix all permissions, ncp-scan still send the same error message :

Home storage for user xxx not writable 
Make sure you're running the scan command only as the user the web server runs as

A search in the below topic show a solution, but I really understand nothing :

Try it with crontab -u www-data -e

This opens the crontab for the user www-data where you can add your cronjob, which will then be run as this user.

Thank you very much, I have remove the cron.daily at root, and I have used crontab -u www-data -e. So far, there is still no improvement for the scan. Maybe I need to wait tonight (after the cronjob) ?

What have you set your cronjob to? But my best guess would be, to wait for the cronjob to run for the first time or change the timing in your cronjob to run at a timeframe you specify, to test the cronjob.

A good suggestion would also be to monitor the cron logs, just to make sure it’s ok or see if there are any errors.

Hello, I have found the issue, but I need your help to not make any mistake to solve it :

  • First I have done sudo nano /etc/rsyslog.conf and have uncommented the #cron line to get all error in the /var/log/cron.log file.
  • Then I have done sudo journalctl -u cron to get all the logs, there were many data including the cronjob for www-data but all seems to be normal.
  • So to be sure to haven’t missed anything, I have done sudo journalctl -u cron -b | grep -i error and have no output (meaning that everything is working as expected).

So I thought “OK, cronjob is working, but I can’t see new files/folders, why ? there shall be a mistake in files path…” …and yes it is !!!

I don’t know why, but NextcloudPi has registered my new data in /media/USBdrive instead of /media/my_custom_path !

As you can see below, I have 2 paths with the same appdata file name and everything almost duplicated, except the new files I have on /media/USBdrive.

I am quite sure, this issue is not related to file permission tweaks, but I suspect the Nextcloud-client app in Linux (I have the latest available version 2.5.1-3 in Debian 10) to have made a new path after I installed it in my laptop.

Now, what I want :

I would like to get back all data from /media/USBdrive to /media/my_custom_path (it is OK to merge and replace new duplicates instead of older files). All I want is to avoid big mistake like erase data. I know that NextclouPi has webUi where you can declare your data folder (this is what I have done to have my_custom_path), but what about the data remaining in /USBdrive ?

Please, how shall I do fix all of this properly and get the Android/Linux clients working again and not create a new /USBdrive again ?

Thank you very much for your kind help !

If you want ncp to automount to /media/my_custom_path
you need to LABEL that drive my_custom_path


Thank you for your help. This is what I did since the very beginning, as you can see on the picture below, I have my disk label, and it seems that USBdrive is a shortcut to this label (so finally, it is not a duplicate but a shortcut), so I don’t think it is related to my issue.

Please, could somebody check if this code gives the same output (I mean do you have your disk label and USBdrive shortcut and same permissions here) ? :


thank you !

Okay, the solution has just been found!
We have discussed to change the permissions of the content of each user’s folders to www-data… but we forgot to change the permissions of the user folders themselves!

It was therefore simply necessary to change also the user folders to www-data :

sudo chown -R www-data:www-data /media/path/to/userfolder

Then, I started an ncp-scan again and everything was finally taken into account!!!

Thank you for your kind help throughout this problem. I hope that this topic will help others in the same situation as me to solve their problems.

And don’t forget: NEVER play with permissions!