Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Truecrypt to secure my data and am obliged to use Dropbox for some file sharing. I've set up my Dropbox folder on the Truecrypt mount.

When I log in Dropbox throws an error, because the Dropbox folder doesn't exist yet. I then have to mount the folder and restart Dropbox.

Is there any way that I can script the following:

  • start Truecrypt, prompting to mount favorite volumes
    • cannot set a time for this as it's based on user input (I have to enter my admin password and Truecrypt password, and I must admit that sometimes I get distracted and make coffee while doing this)
  • only when volume is mounted, start Dropbox
  • options to do this automatically (on login) and manually
share|improve this question
I don't have an answer but a suggestion: how about using EncFS instead of TrueCrypt? That seems a better way of handling this. – Alin Andrei Aug 30 '11 at 10:11
@alinandrei good suggestion, but in my case I want to the cross-platform compatibility offered by truecrypt – d3vid Sep 21 '11 at 8:42
actually using an external tool called BoxCryptor, EncFS works on Windows and Android. I wrote how to get it to work on Android and in the same way it would work on Windows too (you need to tweak EncFS on Linux to be supported on the other platforms, but it works great). – Alin Andrei Oct 5 '11 at 16:33
@alinandrei in my situation someone else controls the Dropbox contents, I want to encrypt the Dropbox folder on my side - I guess I want Dropbox in my TrueCrypt, not TrueCrypt in my Dropbox - if I had more control over the situation I would certainly look into EncFS (or use SpiderOak :) ) - maybe this is a fool's errand and I shouldn't be trying to patch a leaky boat - interesting to learn if it's possible anyway, and I think your comments are valuable for anyone considering something similar – d3vid Oct 7 '11 at 5:27
up vote 2 down vote accepted

I had to do something quite similar. Here is what I ended up doing:

  • remove Dropbox auto start feature of course
  • have Ubuntu auto start the following script:

    #First let's check DB isn't running, you never know
    test "`dropbox status | awk '{print $2}'`" == "isn't" || exit;
    #mount private
    truecrypt --mount #you may optionally indicate which container you wish to mount
    #wait for truecrypt
    while test ! -d /media/truecrypt1/Dropbox
        sleep 1
    #start DB
    dropbox start
share|improve this answer
accepting untested; I no longer need this, but this is the solution I would go for – d3vid Jan 30 '13 at 11:39
@user127252 - This is a good answer. I would suggest a small improvement; use inotifywait to efficiently wait for the mounting. – Paddy Landau Jan 30 '13 at 11:41
@paddy-landau actually, link suggests not – yannack Jan 30 '13 at 11:54
@yannack - thank you for that. – Paddy Landau Jan 30 '13 at 16:11

You can add a script to delay Dropbox from starting up - the link to a dropbox forum question with the answer is here

share|improve this answer
thanks, but the time is variable because I need to enter a password, I've updated the question to clarify this – d3vid Aug 30 '11 at 9:21

iwatch is a commandline tool to allow you to monitor and respond to filesystem events using the inotify subsystem. I'm not sure which event would be best but I would guess that some filesystem event occurs when a filesystem is mounted.

share|improve this answer

Maybe you can parse to df output to discover if the volume is mounted. My Bash-foo is quite feeble, so here is a python script that should do it:

#! /usr/bin/python
# *-*coding=utf-8*-*

"""Try to start dropbox after some volume is mounted"""

import os
import time

MOUNT_POINT = "/home/javier/Private"

mounted = False
while not mounted:
    f = os.popen("df")
    for line in f:
        if MOUNT_POINT in line:
            mounted = True
    if not mounted:
os.system('dropbox start')

You should change MOUNT_POINT to anything that df will output only when the volume is mounted.

I add a more pythonic way of doing it, but harder to port to bash and less flexible, it will need the real mount point.

#! /usr/bin/python
# *-*coding=utf-8*-*

"""Try to start dropbox after some volume is mounted"""

import os
import time

MOUNT_POINT = "/home/javier/Private"

mounted = False
while not mounted:
    if os.path.ismount(MOUNT_POINT):
        mounted = True
os.system('dropbox start')
share|improve this answer

You could try the following batch script. I use this in some of my own scripts that require some pieces I keep within a truecrypt container. Just throw the following in a .bat file. You will have to update some of the code depending on where you store your files and what not.

@echo off

IF EXIST "Z:\" (goto startDropBox)
"C:\Path\To\Truecrypt\truecrypt.exe" /v C:\Path\To\Truecrypt\Volume /lz /a /q


The code assumes you always mount your volume on drive Z. From my experience, the code should hang at the truecrypt log-on screen before proceeding to the next part (running the dropbox executable).

To run this at startup, you could try replacing the dropbox shortcut in your startup folder with this batch file and you could run this manually if you wanted as well.

For other command line switches with Truecrypt look here:

Hope that helps!

EDIT: Just realized this was an ubuntu forum, my bad! But could be nice for wandering Windows users quickly hides

share|improve this answer
you could post the same question and your answer on – d3vid Nov 16 '11 at 6:23

The script should be something like this:

First, create it in your home. Added a dot at the beggining so it will be a hidden file:

gedit .dropboxdelayed

Then, paste this inside:

sleep 20 &&
dropbox start -i &

20 is the number of secconds of delay, don't know how much does truecrypt to mount your encrypted data so you should try it and adapt the number.

Give it permision to run:

chmod +x .dropboxdelayed

And create an entry pointing to it in System>Startup applications (remember to disable the other Dropbox entry there or you will be running two instances of it at the same time).

Whish it helps.

share|improve this answer
thanks, but the time is variable because I need to enter a password, I've updated the question to clarify this – d3vid Aug 30 '11 at 9:21
Ok, even more easy: create the script but before the sleep line, add a line than launches truecrypt (sorry I can't help you with that, haven't used it, but it should end with one &). Then don't put the script in your startup but in a launcher or wherever you prefer. When you launch the script, you'll have 20 seconds to enter your password and when dropbox start, the drive will be allready mounted. – darent Aug 30 '11 at 15:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.