A journey of moving data location of owncloud — Fix ACL Permission Problem

DAMON CHAN
3 min readMar 7, 2019

A journey of moving data location of owncloud

Image is from https://eltechs.com/owncloud-on-raspberry-pi/

Overview

When I started to move my owncloud data directory, it was not an easy thing. I stucked at the folder permission problem, and I tried a couple of hours, I can not figure out why it still can not be changed. However, I found one thing — ACL. I suddenly realise that it must be the real cause! Finally, I remove the ACL control feature on pi folder, everything was fixed.

And now think back to the original task — move the owncloud data directory. Yes, everything is so clear now. When the permission problem fixed, only the database problems left.

How to solve the permission problem?

When you ls -al /media/, you can see that there is a + symbol in the end of pi folder, that means the pi folder is controlled by ACL. Runing the following command can remove the ACL:

setfacl -b /media/pi

Refer to How to remove ACL from a directory and back to usual access control?
How to manage ACLs on Linux

Why I can not start the MySQL server?

When you tried to run sudo systemctl start mysql, but failed. Then you tried to check the log in /var/log/syslog, you found that there was no permission to switch to /var/lib/mysql. That is because the ACL problem, not the soft link problem.

How to move the owncloud data folder?

This is because owncloud is controlled by the database, in my server, although it is mysql server, but it uses MariaDB as the database. But it doesn’t matter. I can still use phpMyAdmin to check and revise the database.

Owncloud database was created when installed and configured via the web. Therefore, when you enter into the phpMyAdmin page, please head to the owncloud database. All data is stored there.

In owncloud’s official website, they listed out the detailed procedures to revise the database. That means, you can not just move the data folder, but also make some changes to the database.
How To Manually Move a Data Directory

Of couse, you can revise the database using the command line.
First connect the owncloud database using mysql root account (the default account, this is used for access all mysql database and you can use it to access the phpMyAdmin as well.

mysql -uroot -p owncloud

Then input the password.
Of course, you can use the owncloud database account to login.

mysql -uowncloud -p owncloud

No root is needed.

How about other services?

When you move the mysql data folder, please revise the other related web services as well.

WordPress: the wp-content folder

sudo ln -s /media/pi/ShareDrive/mysql/wordpress_files /var/www/html/wordpress/wp-content

Gogs: database and repository setting in

/home/git/gogs/custom/conf/app.ini

Normally, the database do not need to change. Because it connect to mysql server using the network. About the repository setting, you just need to specify the new location, that’s it. Of course, the user git shoud be able to access the repository, if just the location is changed, the permission should be kept unchanged.

Redmine: attachment location

Normally, redmine just likes gogs, it connects to mysql server directly, I do not need to care about the location of mysql database. Only the attachment location should be considered (Because my attachment location is managed under the mysql database)
Check the redmine log:

/usr/share/redmine/log/production.log

and open one attachment, log shows:

Cannot send attachment, /usr/share/redmine/instances/default/files/2019/01/190119191549_Lesson-12-Summary.pdf does not exist or is unreadable.

Now you know the real attachment location is

/usr/share/redmine/instances/default/files

Run:

sudo ln -s /media/pi/ShareDrive/mysql/redmine_files /usr/share/redmine/instances/default/files

Once you fix it, you can access the attachment immediately.

Basic: Groups and Permission

Refer to Where is usermod?

--

--

DAMON CHAN

I love Programming, writing, and sharing interesting ideas. I believe only the ideas that we actually live are of any value.