Dropbox Ext4 - ecryptfs

New versions of Dropbox for Linux released after Nov 2018 only support ext4 with xattr enabled, and do not support ecryptfs (Ubuntu's encrypted home folders).

I expect if you use ecryptfs it will continue to work until you update your Dropbox to a newer version with the changes.

The updated Dropbox will work if you stop using ecryptfs or move your Dropbox folder outside of the encrypted directory, though in either of these cases you will need to migrate the files across to the non-encrypted location.

If you require encryption Dropbox will still work on an ext4 partition on top of a block encrypted device, eg using LUKS.

Note that Dropbox is a third party application not provided by Ubuntu itself.


By following this guide I managed to keep the Dropbox folder in my ext4 ecryptfs user home folder. It worked fine on Ubuntu 18.10 without reinstalling Dropbox. I made a few changes to the original guide because i ran into some issues.

Step 1: create a mount point and make it read-only if not mounted

mkdir ~/remote/Dropbox
sudo chattr +i ~/remote/Dropbox

Change the “remote” part of the paths if you prefer to place your Dropbox folder at a different location.

Step 2: create an image file and format it

Change 10G to something that corresponds to the space that you need in order to sync your Dropbox files:

truncate -s 10G ~/remote/.Dropbox.ext4

Format the image with ext4:

mkfs.ext4 -F ~/remote/.Dropbox.ext4

Step 3: create an entry in /etc/fstab

/home/<username>/remote/.Dropbox.ext4 /home/<username>/remote/Dropbox ext4 user,noauto,rw,loop,x-gvfs-hide 0 0

We use the parameter x-gvfs-hide to avoid showing the folder in sidebar of the file manager.

Step 4: use a systemd user service to mount the Dropbox image

Create an new file

touch ~/.config/systemd/user/mountdropbox.service 

edit the file with the following content:

[Unit]
Description=Mounts a Dropbox ext4 image in the home directory of a user
After=home-<username>.mount
Requires=home-<username>.mount

[Service]
ExecStart=/bin/mount %h/remote/Dropbox
ExecStop=/bin/umount %h/remote/Dropbox
RemainAfterExit=yes

[Install]
WantedBy=default.target

Now lets enable and start the service. Slashes must be replaced by dashes if used as systemd parameters.

systemctl --user enable mountdropbox.service
systemctl --user start mountdropbox.service

We also make sure that we own the mounted folder:

sudo chown <username>:<username> ~/remote/Dropbox

Rename old dropbox folder (i.e. /home/<username>/Dropbox)

mv -iv ~/Dropbox ~/Dropbox_old

Create a new symbolic link at the original dropbox path (i.e. /home/<username>/Dropbox)

cd ~ && ln -vs ~/remote/Dropbox Dropbox

run dropbox

dropbox start -i

Step 5: mount the folder before the start of dropbox

in Dropbox preferences, untick the option Start Dropbox on startup

Create a new file and make it executable

touch ~/remote/start_dropbox.sh
chmod +x ~/remote/start_dropbox.sh

Edit file and add this content

#!/bin/sh
systemctl --user enable mountdropbox.service
systemctl --user start mountdropbox.service
dropbox start -i

Rename the original autostart file of dropbox (otherwise dropbox will overwrite it with the original content)

mv -iv ~/.config/autostart/dropbox.desktop ~/.config/autostart/start_dropbox.desktop

Edit the file and modify the Exec Property

Exec=/home/<username>/remote/start_dropbox.sh