ownCloud is enterprise file sync and share that is self-hosted in your data center, on your servers, using your storage. ownCloud provides Universal File Access through a single front-end to all of your disparate systems. Users can access company files on any device, anytime, from anywhere while IT can manage, control and audit file sharing activity to ensure security and compliance measures are met.
WebDAV (Web Distributed Authoring and Versioning) allows you to “mount” your ownCloud content as a local mount point on your local Linux environment.
I prefer this over using the ownCloud client program, as it gives me much more flexibility with my data (e.g. I can rsync directly from CLI from my local storage to the ownCloud and vice versa – effortlessly).
Here’s how I did it:
NOTE: YOU WILL NOT NEED TO BE ROOT TO USE THE MOUNT, BUT ALL OF THESE COMMANDS ASSUME YOU ARE ROOT.
THESE INSTRUCTIONS ALSO ASSUME YOU HAVE A VALID SSL CERTIFICATE FOR YOUR OWNCLOUD HOST. IF YOU DO NOT, REPLACE HTTPS WITH HTTP IN ALL INSTANCES BELOW.
1. Install davfs2
Using your Linux distribution’s package manager, install the ‘davfs2’ package which is available in most all repositories regardless of Linux flavor.
Ubuntu:
# apt-get install davfs2
Fedora/CentOS/RHEL:
# yum install davfs2
2. Create and set permissions for a local mount point for your ownCloud data.
(I prefer mine in /owncloud — replace all instances of ‘youruser’ with your non-root username)
# mkdir /owncloud
# chown youruser.youruser /owncloud
# mkdir ~youruser/.davfs2
# touch ~youruser/.davfs2/secrets
# chmod 600 ~youruser/.davfs2/secrets
# chown -R youruser.youruser ~youruser/.davfs2/
3. Edit ~youruser/.davfs2/secrets with your favorite editor to store your ownCloud credentials:
https://yourdomain.com/owncloud/remote.php/webdav youruser yourpassword
4. Edit /etc/fstab and put the following entry in to tell the filesystem how to mount it:
https://yourdomain.com/owncloud/remote.php/webdav/ /owncloud davfs user,rw,auto 0 0
Note: if you prefer to not have the mountpoint auto mounted each time you log-in, change auto to noauto
5. Add youruser to the ‘davfs2’ group so it can use it.
# usermod -aG davfs2 youruser
Note: you will need to log out and back in to get your new group to take effect
6. Now all you need to do is mount your ownCloud webdav instance
# mount /owncloud
Problems?
On some operating systems, the mount.davfs binary does not have setuid privileges to run as a non-root user. If you see an error such as:
/sbin/mount.davfs: program is not setuid root
You are running an OS that needs the privileges granted. To do so, run this as root:
# chmod +s /usr/sbin/mount.davfs
Want faster rsyncs??
If you’re transferring a large amount of files with rsync, you’ll want to pass it some extra arguments.
Check the rsync man page for:
Enjoy!
Hello,
That’s interesting, unfortunately it’s not very reliable at the moment.
I noticed two problems in particular.
The first is it can be very slow. You cannot use it with unison so basically you cannot use it in any smart way get different copies up to date. http://savannah.nongnu.org/support/?108539 describes the problem and shows that it’s unlikely to change any time soon (partly due to file managers, partly due to the fact it’s monothread)
The second is even more annoying. After one reboot, I had set the relevant line in /etc/fstab in auto mode but did not configure davfs2 to actually select the proper user to mount the partition. It locks the boot process waiting for the partition to be mounted. Overly hardcore problem.
I found that doing apt-get install owncloud-client is much more efficient in the end than any attempt to script and automate the update process otherwise.
I prefer this over FTPfs because unlike owncloud-client, it takes no space on the disk.
Matthieu,
Along with yourfolder/.davfs/secrets ensure that you have the same line at /etc/davfs2/secrets file as well. In my case didn’t ask for passwords after that. Though I must admit, I’m still a bit hesitant to reboot. ^^
Hi,
unfortunately there seems to be no group named davfs2 on my system, which is arch.
Also System won’t boot anymore with that entry in fstab. I needed to remove that in order to get my system booting again.
I am too less admin to know, how to solve that on my own 😀
Nontheless, thanks for your work and explanation!