• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

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

October 23, 2013 by Sharad Chhetri 38 Comments

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 2.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

2.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.

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. Your data directory and files are probably accessible from the internet because the .htaccess file does not work owncloud
  2. How to check default storage engine in MySQL server
  3. How to set default storage engine to MyISAM to InnoDB vice versa
  4. How to know storage engine of mysql table
  5. How to change mysql default data directory in Ubuntu
  6. Keep logs of user after sudo su – : Secondary Logging
  7. How to create iso file from CD/DVD and how to mount .iso file in folder
  8. What is /dev/shm and how to mount /dev/shm
  9. script to change group from a file having list of users
  10. How to list users above or below particular user id

Filed Under: Linux, owncloud Tagged With: owncloud

Reader Interactions

Comments

  1. nick says

    July 29, 2017 at 8:12 am

    Tks,sloved my problem

  2. Sharad Chhetri says

    July 4, 2017 at 2:59 am

    Thank you Paolo!

    Glad to receive your positive comment.

    Regards
    Sharad

  3. Paolo says

    June 29, 2017 at 3:35 pm

    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

  4. Sharad Chhetri says

    December 30, 2016 at 12:27 pm

    Hello David,

    Have a look on this doc. https://help.ubuntu.com/community/MountWindowsSharesPermanently

    Regards
    Sharad

  5. Ivan says

    December 30, 2016 at 6:13 am

    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.

  6. David says

    December 30, 2016 at 12:50 am

    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

  7. Sharad Chhetri says

    December 29, 2016 at 2:58 pm

    Hello David,

    Check the apache error log once. Let me know if you find out any clue there.

    Regards
    Sharad

  8. Sharad Chhetri says

    December 29, 2016 at 2:54 pm

    Hi Ivan,

    No , we have not found any issue as such. Can you paste the error , so that we can know where you are facing the issue.

    Regards
    Sharad

  9. David says

    December 28, 2016 at 8:58 pm

    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

  10. Ivan says

    December 28, 2016 at 11:01 am

    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.

  11. sharad chhetri says

    July 6, 2016 at 4:18 pm

    You are most welcome Abe !

    Regards
    Sharad

  12. abe says

    July 6, 2016 at 7:39 am

    Thanks very much… πŸ™‚

  13. sharad chhetri says

    June 27, 2016 at 4:37 pm

    Hi Henrik,

    We have also updated the /etc/fstab as per our environment and it worked for us.
    Thank You for valuable feedback.

    With Regards
    Sharad

  14. Henrik says

    June 27, 2016 at 12:01 am

    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

  15. sharad chhetri says

    June 19, 2016 at 12:28 pm

    Thank You Henrik,

    Your insight surely will help folks who is opting for this attempt.

    Regards
    Sharad

  16. Henrik says

    June 16, 2016 at 9:52 pm

    Thanks for an excellent guide for someone who is not so familiar with this. I have to things.
    1. I am running ownCloud on Ubuntu 16.04 and this might depend on that, but a correction or remark:
    cp -prvf /var/www/owncloud/data.orig/*.* /var/www/owncloud/data/ did not work for me. It must be
    cp -prvf /var/www/owncloud/data.orig/. /var/www/owncloud/data/

    2. A lot of people get a message from ownCloud that the data directory on the NAS can be red by others and therefore the chmod must be changed to 0770. Even if we do that nothing happens. My problem was actually that the shared folder on the NAS was shared by owncloud AND admin. Remove the permission for admin and that 0770 message is gone and it works fine..
    Thanks,
    Henrik

  17. Brian says

    April 17, 2016 at 8:28 pm

    Helpful. Thank you!

  18. sharad chhetri says

    January 19, 2016 at 4:16 am

    Hello Sam,

    You should rescan the owncloud data directory. Seems you have migrated data from existing owncloud.

    Regards
    Sharad

  19. Sam H says

    January 18, 2016 at 8:52 pm

    I am running Ubuntu 14.04LTS and owncloud Version 8.2.
    1>
    drwxrwx— 5 www-data www-data 4096 Jan 18 14:33 /var/www/owncloud/data

    2>
    drwxrwx— 2 www-data www-data 4096 Jan 14 16:08 data
    drwxrwx— 6 www-data www-data 4096 Jan 11 15:13 engineer
    -rwxrwx— 1 www-data www-data 0 Jan 7 17:36 index.html
    -rwxrwx— 1 www-data www-data 2370 Jan 11 15:29 mount.json
    -rwxrwx— 1 www-data www-data 149504 Jan 18 14:36 owncloud.db
    -rwxrwx— 1 www-data www-data 12396 Jan 11 15:11 owncloud.log
    drwxrwx— 5 www-data www-data 4096 Jan 11 15:01 sales01

    3>
    Filesystem Type Size Used Avail Use% Mounted on
    udev devtmpfs 994M 4.0K 994M 1% /dev
    tmpfs tmpfs 201M 1.1M 200M 1% /run
    /dev/sda1 ext4 72G 4.8G 63G 8% /
    none tmpfs 4.0K 0 4.0K 0% /sys/fs/cgroup
    none tmpfs 5.0M 0 5.0M 0% /run/lock
    none tmpfs 1004M 144K 1004M 1% /run/shm
    none tmpfs 100M 28K 100M 1% /run/user

    4>
    uid=33(www-data) gid=33(www-data) groups=33(www-data)
    id: apache: no such user

    I really just need to have the documents folder and photo folders reside on NAS and not on the Owncloud drive.

  20. sharad chhetri says

    January 18, 2016 at 5:55 pm

    Hi Sam,

    1. First of all I am not sure which Operating System you are using.
    2. Have you checked after mounting do any file or folder exist in /var/www/owncloud/data .

    Mount the NAS first and after this give me command output of –

    ls -ld  /var/www/owncloud/data
    
    ls -l  /var/www/owncloud/data
    
    df -Th
    
    id www-data ; id apache
    

    Regards
    Sharad

  21. Sam H says

    January 18, 2016 at 5:44 pm

    Here’s what I have;
    A folder named owncloud on my NAS server with an address of 192.168.0.10 and I am able to mount it as such;
    sudo mount -t cifs //192.168.0.10/owncloud /var/www/owncloud/test
    I have verified that it mounted.
    Where I run into trouble is when I try to mount this in fstab.
    this is what I enter into my fstab line:
    \192.168.0.10owncloud /var/www/owncloud/data cifs user,uid=33,rw,suid,username=xxxxxxxx,password=zzzzzzzzz,file_mode=0770,dir_mode=0770,noperm 0 0
    then i do this: sudo mount -a and restart apache
    After I do this I can no longer sync on the windows app or connect to the server from the web page.
    I looked in config.php and the data directory is still default but I dont think thats an issue due to mounting the Nas to that data directory.

    Sorry I’m so dense, but I am not sure what the problem is.
    Thanks

  22. sharad chhetri says

    January 18, 2016 at 5:20 pm

    Hi Sam,

    I do not think so, command should work.
    Check the ports or ip address are allowed in your NAS and Server both side.

    Regards
    Sharad

  23. Sam H says

    January 18, 2016 at 4:09 pm

    I cannot seem to mount to my NAS drive no matter what I do.
    Is there per chance changes in this proceedure with the latest version of Ubuntu 14.04 LTS?

  24. Basit Khan says

    October 16, 2015 at 5:32 pm

    Hi,
    Thanks for your tutorial, i just wanna know if i create a shared folder in windows file server, NTFS & Sharing permission are assigned to that folder and I want to mount that folder in own cloud will it work?

    I want if a user browse the file server through explorer or login own cloud, he should be able to view the folder on which he has assigned permission through active directory.

    any help in this regard would be appreciated.

    Thanks

  25. sharad chhetri says

    September 30, 2015 at 2:47 pm

    Hello Clay,

    Thank you for comment. This requirement is quite different and I am happy to see our techy friends getting some idea from this.

    Regards
    Sharad

  26. Clay says

    September 30, 2015 at 4:47 am

    Thank you Sharad! Just what I was trying to accomplish. It worked with a little modification to the mount command line structure on Ubuntu 14.04.

  27. sharadchhetri says

    October 29, 2014 at 2:51 pm

    Hello Schickel,

    I did this task long back ago. Send the output of ls -l command. In this way I am not able to understand your question.

    Regards
    Sharad

  28. schickel says

    October 27, 2014 at 4:43 pm

    Thank you for this guide.

    On my Ubuntu 14.04 I successfully could mount my NAS-share. On the root-dir, and the second one i have write permissions. But if I go to the third dir write premissions are gone. any idea?

  29. sharadchhetri says

    August 13, 2014 at 7:45 pm

    Hello Devin,

    First check the table name oc_appconfig , does it exist in Database.

    Regards
    Sharad

  30. Devin Kolarac says

    August 13, 2014 at 5:24 pm

    After I copied everything, mounted the NAS storage, and restarted apache I got the following error with owncloud:

    An exception occurred while executing ‘SELECT “configvalue”, “appid” FROM “oc_appconfig” WHERE “configkey” = ?’ with params [“enabled”]: SQLSTATE[HY000]: General error: 1 no such table: oc_appconfig

    Can you help? Thanks!

  31. sharad chhetri says

    May 29, 2014 at 2:20 am

    Hello Alex,

    Glad to know the tutorial helped you. Share the tutorial with your friends/colleague.

    Thanks and Regard
    Sharad

  32. Alex says

    May 28, 2014 at 5:53 pm

    Sharad,

    I am a linux idiot / newbie and had to sort out our owncloud. U’re a life saver, and i could give you a kiss!!

    Thanks for sharing the information and its exactly what we needed.

    Cheers!

  33. sharad chhetri says

    May 7, 2014 at 9:53 am

    Hello Greg,

    In CentOS, the web server user name is apache.
    Check the permission and owner/group at /var/www/html/owncloud/data
    data directory you have to create and mount NAS partition with it.
    Carefully read Step 3. First I rename the existing data dir. Then I created a directory with name data. Then I mounted the NAS with data dir

    Can you send me the output of
    cat /etc/fstab (Change username and password from output before sharing)
    df -Th
    ls -ld /var/www/html/owncloud/data

  34. Greg says

    May 7, 2014 at 8:23 am

    . I am using CentOS 6.4. Owncloud is working correct before I make changes described in your tutotail.

    Only thing whay is different that path for Owncloud is /var/www/html/owncloud. I made a simple text in test.html in /owcloud/data/ and this is displayed correctly in the browser

    This is the error on the page

    Can’t create data directory (/var/www/html/owncloud/data)

    You can usually fix this by giving the webserver user write access to the config directory in owncloud */

  35. sharad chhetri says

    May 6, 2014 at 2:14 pm

    Hello Greg,

    Can you give exact error which is displaying on screen ?
    I assume most probably it is permission issue

    Regards
    Sharad

  36. Greg says

    May 6, 2014 at 8:29 am

    Followed but getting error Can’t create data directory (/var/www/html/owncloud/data) in webbrowser. Already disables SELinux which was a problem on the internet

  37. sharad chhetri says

    January 3, 2014 at 5:27 pm

    Welcome Cekage.The practical done with MySQL.Not checked with sqlite.

  38. Cekage says

    January 3, 2014 at 5:01 pm

    Hi,

    Thanks for this memo. If you choose SQLITE and owncloud complains about SQLITE :

    Error while trying to create admin user: SQLSTATE[HY000]: General error: 5 database is locked

    then pass “nobrl” to cifs :
    \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,nobrl 0 0

    Note, SQLITE over CIFS is a *bad* idea.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Commands

Command to create and delete group in Red Hat and CentOS linux

create a system account below uid 500 on RHEL/CentOS/Scientific Linux

grep command to find multiple strings or keyword from file

semanage command not found on CentOS 7 and RHEL 7

Yum command to download rpm file without installing in linux system

Install libjpegtran by using yum command in CentOS 6.x

How to lock and unlock user account in linux

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

Convert new line to space by using sed command

fatal error: error writing to /tmp/ccwAjc9Z.s: No space left on device

Replace keyword with its filename without extension : bash script

linux release renew dhcp assigned ip address

How to change hostname in Ubuntu 12.04 and 12.10 without system restart

How to see line numbers in file through cat command

How to configure ethernet in CentOS 6 after installing in Virtual Box

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

Linux basic command

Linux Basic Commands With Examples For Every Beginner

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

Copyright © 2023 Β·
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy