Tag Archives: Linux

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

Sun xVM Host Interface Networking on Ubuntu

I just struggled a bit with getting xVM’s host interface networking up and running on Ubuntu. It works now and maybe somebody else finds the following short how to useful.

Host Setup

Run “sudo aptitude install bridge-utils”.

Add the following lines to /etc/network/interfaces:

auto tap0
iface tap0 inet manual
  tunctl_user user # replace "user" with the user name running xVM
  uml_proxy_arp sativex-ub

auto br0
iface br0 inet static
  address 10.10.1.1
  netmask 255.255.255.0
  bridge_ports tap0
  bridge_maxwait 0

Run “service networking restart”. (or “/etc/init.d/networking restart” if your Ubuntu doesn’t have the service command yet)

Run “sudo VBoxAddIF vbox0 user br0”. (like above, change “user” to your xVM user)

In your VM settings choose “Attached to: Host Interface”, as “Interface Name” in the field below enter “vbox0”. If you want to have Internet access in your VM you should also configure a second network interface, pick “Attached to: NAT” there.

VM Setup

Start up your VM, and add the following lines to /etc/network/interfaces:

auto eth0
iface eth0 inet static
  address 10.10.1.2
  netmask 255.255.255.0

auto eth1
iface eth1 inet dhcp

Run “service networking restart”.

That’s it, your VM should now be accessible (from your host) via 10.10.1.2. Of course you can adjust the IP addresses/networks as you like.

No Gutsy for me – yet

Five days to go, a release candidate is out and I felt like upgrading – then I noticed that bug #121653 (“fglrx breaks over suspend/resume”) is still open. I have a ThinkPad T60 with an ATI X1400 and I’m using the closed-source fglrx driver, so my setup is clearly affected by this bug.

As a solution I could switch to the free ATI driver, without 3D support, and with somehow degraded 2D performance. I don’t want that. Or I could just stop using Suspend-to-RAM. I don’t want that either. So either I wait until AMD fixed the driver, or I compile my own kernel with the SLAB allocator which is known to work with fglrx. I’m not sure whether the latter really is an option, it probably breaks other modules from the Ubuntu repositories, and I’m not keen on compiling every single piece myself. I’m running Ubuntu, not Gentoo. And the slogan “It Just Works” made me switch from Debian to Ubuntu…

Anyway, this shows once again how important open-source drivers are, and according to reports AMD is working already towards this direction. I will gladly install the open drivers once they are released.