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.
Tks,sloved my problem
Thank you Paolo!
Glad to receive your positive comment.
Regards
Sharad
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
Hello David,
Have a look on this doc. https://help.ubuntu.com/community/MountWindowsSharesPermanently
Regards
Sharad
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.
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
Hello David,
Check the apache error log once. Let me know if you find out any clue there.
Regards
Sharad
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
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
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.
You are most welcome Abe !
Regards
Sharad
Thanks very much… π
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
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
Thank You Henrik,
Your insight surely will help folks who is opting for this attempt.
Regards
Sharad
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
Helpful. Thank you!
Hello Sam,
You should rescan the owncloud data directory. Seems you have migrated data from existing owncloud.
Regards
Sharad
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.
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 –
Regards
Sharad
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
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
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?
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
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
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.
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
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?
Hello Devin,
First check the table name oc_appconfig , does it exist in Database.
Regards
Sharad
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!
Hello Alex,
Glad to know the tutorial helped you. Share the tutorial with your friends/colleague.
Thanks and Regard
Sharad
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!
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
. 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 */
Hello Greg,
Can you give exact error which is displaying on screen ?
I assume most probably it is permission issue
Regards
Sharad
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
Welcome Cekage.The practical done with MySQL.Not checked with sqlite.
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.