How to Auto-Mount Box.net to Linux Desktop

If you are one of the lucky few, you might have already received the 50GB storage upgrade to your Box (previously known as Box.net) account by installing its Android app. The next question is, what should you do with the extra storage space? The most logical solution is to install its sync software on your computer so you can sync files from your desktop and on every computer/OS you use, much like the Dropbox way. The only problem is, such sync software doesn’t exist.

Unlike Dropbox, Box doesn’t come with any sync software for the personal account. If you upgrade your account to the Business and Enterprise editions, you can download the sync software for Mac and Windows. So if you are using Linux, you are almost out of luck.

Luckily, Box does support WebDav. This means that you still can connect to it from your Linux desktop, though the solution is not as elegant as the Dropbox sync.

Here is how you can connect to Box from Linux.

Note: This tutorial is based on Ubuntu, Gnome Shell and Nautilus.

1. Open Nautilus. Go to “File -> Connect to Server”.

2. Under the Type dropdown, select the option “Secure WebDav (HTTPS)”. Next, enter the URL “www.box.com/dav” in the server field (do not put https:// in front of the URL).

3. Enter your Box username and password.

box-connect-to-server-from-nautilus

4. Press “Connect”. You should be connected to your Box account now.

When you use the above method, you will find that the connection does not persist. You will have to connect to the Box server every time you login. Here is one method where you can auto-mount your Box account. We will be using davfs. Here is what you need to do:

1. Open a terminal and install davfs:

sudo apt-get install davfs2

2. Add your Linux user account to the davfs2 group. Replace “your-username” with your Linux login username

sudo adduser your-username davfs2

3. Create a folder in your Home directory to mount your Box account. In addition, also create the .davfs folder to hold your configuration files.

mkdir ~/Box
mkdir ~/.davfs2

4. Next, copy the davfs configuration file over and add the “user_lock” command to it:

cp /etc/davfs2/davfs2.conf ~/.davfs2
echo "use_locks    0" >> ~/.davfs2/davfs2.conf

5. Open a text editor and paste the following, replacing “Box_username” and “Box_password with your Box account login username and password (make sure the quotes around the Box_password remain).

https://www.box.com/dav     Box_username    "Box_password"

Save the file as “secrets” (without the quotes and without any extension) in the .davfs2 folder.

Back to the terminal, change the permission of the secrets file so it can only be read/write by you.

chmod 600 ~/.davfs2/secrets

6. Next, open the davfs2.conf file (in the .davfs2 folder) with a text editor. Scroll down the list until you find the entry (at around line 24):

ignore_home       kernoops,distccd  # system wide config file only

Insert a “#” so it becomes:

#ignore_home       kernoops,distccd  # system wide config file only

Next, scroll down further until you find the entry (at around line 35):

# secrets         ~/.davfs2/secrets # user config file only

Remove the “#” so it becomes:

secrets         ~/.davfs2/secrets # user config file only

Save and close the file.

7. Now, we are going to add a new entry to your /etc/fstab file:

sudo nano /etc/fstab

Add the following line to the end of the file (paste using the shortcut key “Ctrl + Shift + v”). Replace “your-username” with your Linux login username.

https://www.box.com/dav /home/your-username/Box         davfs rw,user,noauto 0 0

Save (using “Ctrl + o”) and exit (using “Ctrl + x”). Open Nautilus. You should see a Box entry at the filesystem column (the entry appears, but it is unmounted at the moment, so you won’t be able to access it)

box-entry-showup-in-nautilus

8. To test if the mounting works, type in the terminal:

mount ~/Box

If everything goes fine, your Box account should be mounted and show up in your Nautilus. If not, check your Box username and password in the “secrets” file.

Update: Some of you might see the user permission error when mounting it. If so, change the davfs2 user permission:

sudo chmod u+s /sbin/mount.davfs

Thanks to StoyanDeckoff for the tips.

9. Lastly, open up your Startup Applications and add a new item with the command:

mount ~/Box

box-mount-on-startup

That’s it. Your Box account should be mounted whenever you login to your desktop.