how to mount NAS storage in owncloud to keep all users data

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.

38 thoughts on “how to mount NAS storage in owncloud to keep all users data”

  1. This is exactly what I was trying to do!
    I followed your instructions and everything was fine.
    Your how-to is GREAT, really. Many many thanks! 🙂

    Paolo

    Reply
  2. Sorry to Revive an old thread. I am current trying to move my data directory to a windows network share. I have tried everything within the thread and also done a lot of research to try and accomplish this but i am still unsuccessful. Do you guys have any pointers that i can try.

    Cheers David

    Reply
      • Afternoon Sharad,

        I have looked in the Apache error.log file and from what i can see the last error occurred on the 15th. I have been playing around with it for afew hours tonight and i have made some progress i think :P. I have installed cifs-utils and then when i ran the mount -a command it asked me for the password for my Windows account, which i type in but i then get this error “CIFS VFS: Send error in sesssetup= -13″”CIFS VFS: cifs_mount failed w/return code = -13″”Mount error(13) : Permission denied””Mount: mount point 0 does not exist” Do you have any ideas ? PS this is the first time i have used linux in an real capacity so it may be something simple that i am missing 😀

        Also i have tried to mount the drive through fstab file using a .smbcredentials file but this also pops the same error as above.

        side note i can mount the drive without issues manually but any attempt to do this automatically through the fstab file fails.

        Cheers David

        Reply
  3. Hello Sharad Chhetri

    Could you please tell me, have you ever expirienced any issues because of Apache startup before network share become mounted?

    Thank you for sharing your expirience.

    Reply
      • Hello Sharad Chhetri

        I’m doing preparations to such migration and collecting any relevant information. So, at the moment, I do not have any issues with that.

        Thank you for your prompt reply.

        BR.

        Reply
  4. I have another comment to this chmod 0770. After moving ownCloud to run on a VMware ESXi the problem was back. I had to do the following change in /etc/fstab:
    – add gui
    – change from noperm to nounix That keeps the Library 0770.

    \192.168.1.10owncloud /var/www/owncloud/data cifs user,uid=29, gui=29,,rw,suid,username=NAS_user,password=NAS_password,file_mode=0770,dir_mode=0770,nounix 0 0

    Now it runs like a charm.
    -Henrik

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.