Move or Bind Owncloud Data Directory to an external hard drive

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 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.
  1. 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)
  2. Stop your webserver service (updated on March 4, 2017)
    apache2: sudo service apache2 stop
    nignx: sudo service nginx stop
  3. Copy your data directory to the new location
    cp -rT /var/www/owncloud/data/ /media/user/your_hard_drive/owncloud_data/
  4. Rename your data directory to avoid confusion
    mv /var/www/owncloud/data /var/www/owncloud/data_original
  5. 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/
  6. Make the folder that will be mounted
    mkdir /var/www/owncloud/data
  7. 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
  8. Make the mount
    mount --bind /media/user/your_hard_drive/owncloud_data/ /var/www/owncloud/data/
  9. Verify your server is up and running.
    apache2: sudo service apache2 restart
    nginx: sudo service nginx 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.

Comments