By default, OwnCloud will store all the data inside /var/www/owncloud/data directory. The best way is to move all the files and folder inside the folder to the data-disk, and then mount the data-disk as /var/www/owncloud/data. This is how you can do it. These steps presume that the data-disk is mounted as /data, which is the default.
1. Stop Apache service:
service apache2 stop
2. Go to /var/www/owncloud/data folder, and then move all the contents inside the folder to /data, which is the data-disk mount point. There are some files beginning with dot (.) e.g. .htaccess and .ocdata which needs to be moved manually.
cd /var/www/owncloud/data
mv * /data
mv .htaccess /data
mv .ocdata /data
3. Un-mount the data-disk:
umount /data
4. Then, modify /etc/fstab so that the data-disk is mounted as /var/www/owncloud/data instead of /data. You can use vi or pico to modify the file:
pico /etc/fstab
Modify this line:
UUID=XXXXXXXXXXXXXXXXXXXXXXXXXXX /data ext4 errors=remount-ro 0 2
Change /data to /var/www/owncloud/data.
5. Mount back the data-disk, it should be mounted as /var/www/owncloud/data now:
mount -a
6. Verify that it's mounted as /var/www/owncloud/data by using df:
df
Example:
root@Ubuntu14041-64b-owncloud:/# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vda1 8124856 2024104 5664992 27% /
none 4 0 4 0% /sys/fs/cgroup
udev 498128 4 498124 1% /dev
tmpfs 101796 384 101412 1% /run
none 5120 0 5120 0% /run/lock
none 508964 0 508964 0% /run/shm
none 102400 0 102400 0% /run/user
/dev/vdb1 20510332 51336 19394088 1% /var/www/owncloud/data
7. Change the owner of /var/www/owncloud/data from root:root to www-data:www-data:
chown -R www-data:www-data /var/www/owncloud/data
8. Lastly, restart back Apache service:
service apache2 start