In this post I am sharing about how I mounted the NAS storage in owncloud to keep all users data in it.
I checked the External Storage application of owncloud but here our requirement is we want to keep all data in NAS storage and user should not save anything in Owncloud Server’s disk.
The main trick is mounting part.
Scenario: Keep all user’s data in NAS storage and user should not save anything in Server hard disk.
Solution: For this trick,the owncloud should be installed in your server and working.In ownloud DocumentRoot there is one directory called data. We will mount NAS storage to data directory.
Step 1: Login into your NAS server and create a shared folder with username and password.I have use IOmega NAS server. The shared directory in NAS server should be accessed via Windows sharing (aka CIFS filesystem)
Step 2: Now login into Linux server in which you have installed owncloud.
In my server(Ubuntu) the DocumentRoot is /var/www/owncloud.
Hence the path of data directory is /var/www/owncloud/data
First of all check .are you able to mount NAS storage temporarily
Syntax:
mount -t cifs \NAS-Server-IP-addressSharedFolder-Name mounting-Directory -o username=give_username,password=give_password
eg.
mount -t cifs \192.168.1.10owncloud mnt -o username=owncloud-nas,password=owncloud_password
If you are able to mount successfully now unmount the partition
eg.
umount /mnt
Step 3: Now we will permanently mount the NAS storage.But before this we have to do some changes
Copy the data directory of owncloud
cp -prvf /var/www/owncloud/data /var/www/owncloud/data.backup
Now rename original owncloud’s data directory ,create new data folder,copy the contents from original data directory and change ownership and permission
mv /var/www/owncloud/data /var/www/owncloud/data.orig mkdir -p /var/www/owncloud/data cp -prvf /var/www/owncloud/data.orig/* /var/www/owncloud/data/ cp -prvf /var/www/owncloud/data.orig/*.* /var/www/owncloud/data/ chmod -R 770 /var/www/owncloud/data ; chown -R www-data:www-data /var/www/owncloud/data
Note: www-data is apache user in Debian and Ubuntu,if you are using Red Hat or CentOS replace www-data with apache word.
Get the uid of www-data or apache user by using id command
id www-data (For ubuntu and Debian) OR id apache (For CentOS and Red Hat)
Edit the /etc/fstab for permanently mounting NAS storage
Add the given below line in /etc/fstab ,it is just an exmaple. (As per your information change the ipaddress with your NAS server ip address, id no. of your apache user,NAS username and password)
vi /etc/fstab \192.168.1.10owncloud /var/www/owncloud/data cifs user,uid=29,rw,suid,username=NAS_user,password=NAS_password,file_mode=0770,dir_mode=0770,noperm 0 0
Now run below command to mount the NFS storage without server restart
mount -a
Step 4: Restart the apache of linux server
/etc/init.d/apache2 restart (For Ubuntu and Debian) /etc/init.d/httpd restart (For CentOS and Red Hat)
Step 5: Now test the owncloud server. Create some user,upload some testing files.
The user;s data directory will be created in /var/www/owncloud/data with their respective username.
If possible login to NAS server dashboard and check the shared folder, you will see uploaded testing files there.