When installing OwnCloud, you will probably have an external hard drive that you will want to have as your data directory. You can place the entire owncloud directory on your hard drive but this will result in slower performance when really all the large data files will be in /data. By moving /data, you have gigabytes or terabytes of extra storage that your desktop machine cannot run. Getting OwnCloud to recognize that external hard drive is tougher that you think. Here is my solution following the different threads I found online:
You could change /var/www/owncloud/config/config.php ‘s datadirectory to look at the new location, but that never worked for me. Rather, we are going to create a mount point and not a symbolic link. The symbolic links have a permission issues that “mackey” discovered and they will cause you a huge headache.
- Notes before reading:
- Some of these may need a
sudoin front to execute.
- You can apply stricter permissions in the chmod step.
- If you mess up the mount step, you can edit
/etc/mtabto remove your mounts or you can use
umount folder_you_mountedto clean up your mounts.
- Some of these may need a
- So, create your folder on your hard drive, let’s call it
mkdir /media/user/your_hard_drive/owncloud_data (Updated on 3/12/2015)
- Stop your webserver service (updated on March 4, 2017)
apache2: sudo service apache2 stop
nignx: sudo service nginx stop
- Copy your data directory to the new location
cp -rT /var/www/owncloud/data/ /media/user/your_hard_drive/owncloud_data/
- Rename your data directory to avoid confusion
mv /var/www/owncloud/data /var/www/owncloud/data_original
- Apply the proper group and read permissions onto the hard drive’s data directory
chown -R www-data:www-data /media/user/your_hard_drive/owncloud_data/
chmod -R 755 /media/user/your_hard_drive/owncloud_data/
- Make the folder that will be mounted
- Apply the proper permissions onto this soon-to-be-mounted folder
chown -R www-data:www-data /var/www/owncloud/data
chmod -R 755 /var/www/owncloud/data
- Make the mount
mount --bind /media/user/your_hard_drive/owncloud_data/ /var/www/owncloud/data/
- Verify your server is up and running. (added on Jan 9, 2016) (updated on March 4, 2017)
apache2: sudo service apache2 restart
nginx: sudo service nginx restart
- Verify you can access your owncloud server (typically localhost/owncloud)
- Verify in top right Username>Personal that you have a large amount of storage space left.
hello, thanks for this .
how can i give plex access to thie new /user/owncloud_data/ folders ?
Access is all about permissions. So either make the /user/owncloud_data/ folders 777 with chmod 777 /user/owncloud_data/ or you can try adding plex to the group that owns owncloud_data.
cheer mate, this really helped me! On the first line it should be mkdir instead of mdkir, however. Keep up the good work!
You might want to add:
sudo service apache2 start
before checking to see if site works.
I will add that to the article. Thank you.
Not working on a Raspberry pi 2 running nginx. Any ideas?
When I tried tried to do step 4 it wouldn’t allow me to. Said it was in use or busy. I did all the other steps, but it’s still showing that I only have 28GB of room and it should be much closer to 1 TB
Are you in the directory you want to move?
At step 2 add:
sudo service nginx stop
(to shutdown the webserver, now the dir should no longer be busy) – now continue the guide.
At step 9 add:
sudo service nginx start
(to startup the webserver)
Hope this could help
Pingback: Moving OwnCloud to a new home | Man and Keyboard
Thank’s for the info!
It’s needed to re-mount the directory when restart the server?
I am not sure exactly what you are asking, but yes. When the server or computer is restarted, you will need to re-mount the directory each time.
I have been struggling a lot for a few days now trying to get Nextcloud working on an external HDD: Indeed, my approach has been to change the datadirectory in /var/www/html/nextcloud/config/config.php, and that just isn’t working.
Your solution seems great, but I hesitate because of what you say here: having to manually re-mount the directory doesn’t sound like an attractive option.
Is there a way to automate this?
You can try using the external hard drive plug-in. Your hard drive will appear as a folder in your Nextcloud where you can save files.
Thanks for the article.
If you want to avoid the mount issue with restart you can add the mount to /etc/fstab. Below is my entry mounting to a NFS server.
192.168.1.132:/share/OwnCloud /var/www/owncloud/data nfs defaults
Is your Owncloud works fine through NFS? What OS version? Did you do any special steps for it except ensuring the right permissions, startup and mounting? Thanks in advance
Hello man, this is great!
It worked with nextcloud 10.0 version I guess is the right version. Of course we just have to change the name of “owncloud”
If you don’t mind I will copy the steps that I did with NextCloud which are pretty much the same, I did a research so deep into the folders but I will copy the steps for everyone to be easy to understand:
Just remember to replace with your own values the words
(Updated on 11/19/2016)
1. Create your folder on your hard drive, let’s call it:
sudo mkdir /media/user/your_hard_drive/nextcloud_data
2. Stop your apache2 service
sudo service apache2 stop
3. Copy your data directory to the new location
sudo cp -rT /var/www/html/nextcloud/data /media/user/your_hard_drive/owncloud_data/
4. Rename your data directory to avoid confusion
sudo mv /var/www/html/nextcloud/data /var/www/html/nextcloud/data/data_original
5. Apply the proper group and read permissions onto the hard drive’s data directory
sudo chown -R www-data:www-data /media/user/your_hard_drive/nextcloud_data/
sudo chmod -R 777 /media/user/your_hard_drive/nextcloud_data/
6. Make the folder that will be mounted
sudo mkdir /var/www/html/nextcloud/data
7. Apply the proper permissions onto this soon-to-be-mounted folder
sudo chown -R www-data:www-data /var/www/html/nextcloud/data
sudo chmod -R 777 /var/www/html/nextcloud/data
8. Make the mount
sudo mount –bind /media/user/your_hard_drive/nextcloud_data/ /var/www/html/nextcloud/data
9. Verify your server is up and running
sudo service apache2 restart
10.Verify you can access your owncloud server (typically localhost/owncloud)
11.Verify in top right Username>Personal that you have a large amount of storage space left.
12. Also I created some random folders on nextcloud and some text files to check if were on the usb hard drive and were created correctly since I plan to have the orange pi server connected and whenever I need to take the drive with me I have everything on it and it worked flawlessly. In addition, I formatted the USB drive as NTFS and worked on Windows as well without additional programs
Hope this helps for someone else with NextCloud as well 🙂
Pingback: Best Nextcloud 11 Links | Man and Keyboard
Thanks for the writeup, works like a charm.
After so many trials, where either setting another data directory failed altogether, or at least somehow was not recognized and the space still limited to the few MB left on my SD, this right here has eventually made it work.
Great job, and I can’t express my gratitude enough after all these hours!!
Hi, I am using Nextcloud snap straight on Ubunutu 18.04 (no apache2 or nginx). The only way to be able to read and write files on the Nextcloud browser interface is by setting chmod to 777 for the mount point. Any idea what I can do to avoid this?
You can lower the world permissions to zero, like 770. And I don’t think you need the execute permissions as well.
Setting permissions to 770 didn’t work with the Snap Nextcloud setup; the only parameter that allowed access from Nextcloud to the external drive was 777. I have since started over with a regular LAMP setup and Nextcloud, and I can set user permissions for the external drives to 755 and access the drive.