Mounting Remote WebDAV Drives in Linux

Published: May 20, 2020

Mounting remote folders using 4shared and bitrix24 as examples. Over time, I plan to add configuration instructions for more services.

Want convenient access to remote folders from your Raspberry? Why would I need that? There are plenty of uses. You can run scripts that add files to the drive, expand your storage space and, most importantly... BACKUP! I probably don't need to explain how important that is. I've already had 2 failures of my Raspberry, mostly caused by power loss. Nightly backups saved me. Let's get started!

Installation

Installation is very simple. First, update the package list.

sudo apt-get update

Then install the required module.

sudo apt-get install davfs2

We can allow users without administrator privileges to mount drives.

sudo dpkg-reconfigure davfs2

Now we need to add our user to the davfs2 group (if your user has a different name, enter it instead of pi.

sudo adduser pi davfs2

4shared

4shared is a file hosting service that gives users as much as 15 GB of storage. Creating an account is free, of course, although the transfer speeds are nothing special. Still, it will be perfect for nightly backups of basic data!

Create a folder where you want to mount the remote drive.

sudo mkdir /media/4shared

Open the configuration file containing the passwords.

sudo nano /etc/davfs2/secrets

Then add the following at the end, of course entering your own details in the login and password fields.

# personal webdav 4shared
/media/4shared login hasło

Close the file and save the changes (ctrl+x and confirm). Now mount the drive.

sudo mount -t davfs -o noexec https://webdav.4shared.com/ /media/4shared

If the folder mounted successfully, unmount it. We'll now add it to automatic mounting.

sudo umount /media/4shared

To enable automatic mounting, we need to open the fstab configuration.

sudo nano /etc/fstab

Then add the following line at the end. Notice that we don't provide any passwords here (we already saved them in the configuration file). The auto parameter means that the file server will be mounted when the system starts. Remember to enter your login.

#4shared mount
https://webdav.4shared.com/ /media/4shared davfs _netdev,auto,user,uid=login,gid=login 0 0

Close the file and save the changes (ctrl+x and confirm). Mount the newly added drive.

sudo mount -a

Finally, set the correct permissions so you can manage files without having to run commands through sudo. The R parameter means that the permissions will be applied to all files and folders.

sudo chown -R pi:davfs2 /media/4shared

While running this command, you will see the message below, which you don't need to worry about.

bitrix24

Bitrix24 is a CRM service designed to make running a business easier. What interests us, however, is what it offers in the free version — a 5 GB drive with very good data transfer speeds. It also includes many other useful tools for managing a company, tasks and employees, but that's not what this post is about. It's worth knowing that bitrix24 guarantees data privacy based on EU regulations.

Hosted in Germany

Your data is stored in two European Amazon Web Services data centers in Frankfurt am Main (Germany). These data centers fully comply with EU data protection regulations, including Directive 95/46/EC.

You can also purchase a version of Bitrix24 that is hosted in your own country and on your own server. AWS supports the following certifications: HIPAA, DSGVO, ISO 27001, SOC 1/2/3 and PCI DSS Level 1.

Bitrix, Inc. is committed to complying with the General Data Protection Regulation (DSGVO), which will apply from May 25, 2018.

I won't describe the registration process because everyone should be able to handle that. Instead, I'll go straight to configuring the remote drive mount.

First, you need to get the link to your drive. To do this, log in to your bitrix24 account. In the sidebar on the left, select Bitrix24.Drive (as shown in the screenshot below).

Now click the gear icon in the top-right corner and select the Network Drive option.

A window will appear containing the address of our network drive. Copy it because we'll need it.

Create a folder where you want to mount the remote drive.

sudo mkdir /media/bitrix24

Open the configuration file containing the passwords.

sudo nano /etc/davfs2/secrets

Then add the following at the end, of course entering your own details in the login and password fields.

# personal webdav bitrix24
/media/bitrix24 login hasło

Close the file and save the changes (ctrl+x and confirm). Now mount the drive. Remember to use your own link below — the one you copied from the bitrix website.

sudo mount -t davfs -o noexec https://TUWPISZSWOJEDANE.bitrix24.pl/company/personal/user/1/disk/path/ /media/bitrix24

If the folder mounted successfully, unmount it. We'll now add it to automatic mounting.

sudo umount /media/bitrix24

To enable automatic mounting, we need to open the fstab configuration.

sudo nano /etc/fstab

Then add the following line at the end. Notice that we don't provide any passwords here (we already saved them in the configuration file). The auto parameter means that the file server will be mounted when the system starts. Remember to enter your drive address and login.

#bitrix24 mount
https://TUWPISZSWOJEDANE.bitrix24.pl/company/personal/user/1/disk/path/ /media/bitrix24 davfs _netdev,auto,user,uid=login,gid=login 0 0

Close the file and save the changes (ctrl+x and confirm). Mount the newly added drive.

sudo mount -a

Finally, set the correct permissions so you can manage files without having to run commands through sudo.

sudo chown -R pi:davfs2 /media/bitrix24

While running this command, you will see the message below, which you don't need to worry about.

Other services

I also plan to add Dropbox. Adding Google Drive won't be as simple, however, because it doesn't support WebDAV, which makes the process more complicated. I'll probably cover that in another post.

Comments (3)

  1. Daniel

    Witam Mam pytanie, czy przy poleceniu do automatycznego montowania dysku login podajemy w: uid=login czy gid=login czy może w obydwu parametrach?

    1. pablo
      Reply to: Daniel

      ja podałem w obydwu parametrach

  2. jerzy

    świetny blog, trafiłem z googla i czytam kolejne wpisy, prosto i praktycznie

Add a comment

Comments are published after moderation. Your e-mail address stays private.