Tag Archives: workaround

Dropbox on Linux with encrypted home directory

Dropbox dropped support for all files systems except ext4 on Linux. This is a problem for everybody using an encrypted home directory since those are usually mounted via ecryptfs or similar. The following workaround makes use of an ext4 formatted file system image that is mounted via a loopback device upon login.

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

Alternative way of creating the image using dd:

dd if=/dev/zero of=remote/.Dropbox.ext4 count=10240 bs=1048576

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 upon user login

Create the file .config/systemd/user/mountdropbox.service 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

After executing the commands above the service will be started (i.e., the Dropbox folder will be mounted) automatically upon user login.

Note for Ubuntu 18.04 or newer: for some reason systemd seems to “forget” the user service after reboot. Please check the comments of this blog post for a solution to this.

We also make sure that we own the mounted folder:

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

Step 5: tell Dropbox to move your files to the new location

You can use the Dropbox GUI to move the Dropbox folder location to the newly created one.

The way how Dropbox detects the file system in use is a bit awkward as it does not let you choose the mount point itself as Dropbox folder location, instead you need to sync to a subfolder. So if you mount point is remote/Dropbox you need to sync to remote/Dropbox/<username> or something like that as Dropbox does not believe that the mount point is an ext4 file system.

Optional: grow the Dropbox image if you need more space

On the command line run the following commands (change 15G to something appropriate for your needs, but never change it to a lower size than your existing image as this cuts of the image which may lead to data loss):

dropbox stop
systemctl --user stop mountdropbox.service
truncate -s 15G remote/.Dropbox.ext4
fsck.ext4 -f remote/.Dropbox.ext4
resize2fs remote/.Dropbox.ext4
systemctl --user start mountdropbox.service
dropbox start

Fixing IntelliJ IDEA font glitch on Ubuntu

This post is mostly for myself to remember what changes to make in IntelliJ IDEA. The problem is that fonts are ugly and not antialized in stock-IDEA. In my case it affects IDEA 13 and 13.1 so far.

The problem is still not completely solved, the fonts are looking better, but still not as good as in Eclipse. Don’t ask me why, I just don’t know.

After googling for a good while I came up with the following additions that improve how fonts are rendered:

In idea64.vmoptions add the following lines:

-Dawt.useSystemAAFontSettings=on
-Dswing.aatext=true
-Dsun.java2d.xrender=true

At the very end of idea.sh exchange the following line

eval "$JDK/bin/java" $ALL_JVM_ARGS -Djb.restart.code=88 $MAIN_CLASS_NAME "$@"

for

eval "/usr/lib/jvm/jdk-7-oracle-x64/bin/java" $ALL_JVM_ARGS -Djb.restart.code=88 $MAIN_CLASS_NAME "$@"

This is to make sure that Oracles JDK is used as there seems to be a problem with OpenJDK and fonts in IDEA (even though this works in Eclipse). Make sure you use the path that is correct for your JDK.

While at it I also increased the default memory settings and my complete idea64.vmoptions looks like this now:

-server
-Xms256m
-Xmx2048m
-XX:MaxPermSize=512m
-XX:ReservedCodeCacheSize=256m
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:+UseCodeCacheFlushing
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-Dawt.useSystemAAFontSettings=on
-Dswing.aatext=true
-Dsun.java2d.xrender=true