Ubuntu server: move Owncloud data folder to external hdd
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.
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 sudo in front to execute.
- You can apply stricter permissions in the chmod step.
- If you mess up the mount step, you can edit /etc/mtab to remove your mounts or you can use umount folder_you_mounted to clean up your mounts.
- 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 apache2 service
sudo service apache2 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 777 /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 777 /var/www/owncloud/data
- Make the mount
mount –bind /media/user/your_hard_drive/owncloud_data/ /var/www/owncloud/data/
- Start apache service
sudo service apache2 start
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.