I’m new to Nextcloud so I installed it via "Snap"to an existing Ubuntu installation. But before I installed NextCloud I added an additional 2 gig hard drive for data storage.
I followed this tutorial: https://linuxhint.com/install_nextcloud_ubuntu/ and everything seemed to go ok. I then followed this tutorial: Tutorial: How to migrate mass data to a new NextCloud server to migrate some files and data. Everything seemed to go fine until I needed to run this command:
sudo -u www-data php console.php files:scan --all
With the install via Snap I didn’t have a WWW directory. So after a little searching I came up with these commands below. All three scan commands get the same output listed below.
The data is on the drive, I can see it on a file browser but I can’t see it on a web browser. I can’t get a scan to work. I think I have a permissions issue with my data drive. Please see below. Can someone please help me with this?
bart@bart-Server:~$ sudo df -h | grep nextcloud
[sudo] password for bart:
/dev/loop4 233M 233M 0 100% /snap/nextcloud/20498
/dev/sda1 1.8T 526G 1.2T 31% /var/snap/nextcloud/common/nextcloud/data
bart@bart-Server:~$ sudo nextcloud.occ files:scan --all
bart@bart-Server:~$ sudo nextcloud.occ files:scan
bart@bart-Server:~$ sudo /snap/bin/nextcloud.occ files:scan --all
[sudo] password for bart:
Your data directory is not writable
Permissions can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/18/go.php?to=admin-dir_permissions.
An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /snap/nextcloud/20498/htdocs/lib/private/Console/Application.php:167
#0 /snap/nextcloud/20498/htdocs/console.php(98): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /snap/nextcloud/20498/htdocs/occ(11): require_once(’/snap/nextcloud…’)
After a week of investigation I have finally solved this problem. I used these commands:
$ sudo snap disable nextcloud
$ sudo chown -R root:root /media//<hard_drive_name>/nextcloud_data_directory
$ sudo chmod -R 0770 /media//<hard_drive_name>/nextcloud_data_directory
Re-enable your Nextcloud server
$ sudo snap enable nextcloud
$ sudo nextcloud.occ files:scan --all
I honestly only made this account to comment on this. The search for a solution to my problem has finaly come to an end after days! THANK YOU SO MUCH!!!
Sorry, but I still get
“Exception during scan: opendir(my_data_dir): failed to open dir: Permission denied”
Both ownership and permissions are ok, root:root and 0770. Files are writable from root. So I don’t understand why there is a permission problem. Does nextcloud.occ run under another account?
Hi wa_bo, I’m not the best qualified to help but for anyone to understand your problem you will have to provide more information. I ended up deleting my snap install as there was very little help on the forum for snap installs. I did a re-install following this how to guide:
It was very easy to follow and worked straight away and any issues that I have had there seems to be more information out there for the conventional install. He also has another method of install which I try next time. See link below.
But as I said before, if you want to solve your snap install we would need more information. I hope this helps.
Thanks for your fast reply!
I have searched around at it seems as it boils down to that snap installations are not allowed to reach outside the snap environment, at least not without extra measures. Regardless of the ownership and permissions on the external drive.
Thanks very much for the links. I’ll study the carefully!
To access removable media I used the following command…
sudo snap connect nextcloud:removable-media
As per this youtube video…
I love this man. Just spend last 3 days on this and couldn’t solved it. BUT THIS WORKED. THANKS
Glad I could be of help. It is a bit of a journey, but its worth it in the end. Good luck.
I’ve used the information in this post to fix my occurence of this error, but it keeps coming back randomly.
Is there anything I should be looking at to explain why I keep getting this error?
I would be looking at when the change back occurs. Does this happen after an update as some Nextcloud system files that we have modified are replaced by the default versions during the update process. For example I have to change the time out values in one of my php files in order to get the Nextcloud app store to work after every update. Each update returns the value to the default. Hope this helps.
Until yesterday, I couldn’t find any specific action when it occurred. The snap updates automatically, so I don’t know when it happens.
However, I checked dmesg yesterday and it turns out that the drive in question is an ext4 file system and had an aborted journal which caused the drive to be mounted read only.
I have now repaired the journal and rebooted the computer several times, and so far seems to be working.
If I continue to have journaling problems, I’ll have to move the data to another, more reliable drive, and retire the current one.